-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add typings to org repo * fix: ci & tests
- Loading branch information
1 parent
1caff82
commit 43de985
Showing
7 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Definitions by: Jannik Keye <https://github.com/jannikkeye> | ||
|
||
import busboy = require("busboy"); | ||
import fastify = require("fastify"); | ||
|
||
import { Server, IncomingMessage, ServerResponse } from 'http'; | ||
|
||
type MultipartHandler = ( | ||
field: string, | ||
file: any, | ||
filename: string, | ||
encoding: string, | ||
mimetype: string, | ||
) => void; | ||
|
||
declare module "fastify" { | ||
interface FastifyRequest<HttpRequest> { | ||
isMultipart: () => boolean; | ||
multipart: (handler: MultipartHandler, next: (err: Error) => void) => busboy.Busboy; | ||
} | ||
} | ||
|
||
declare const fastifyMultipart: fastify.Plugin<Server, IncomingMessage, ServerResponse, { | ||
limits?: { | ||
/** | ||
* Max field name size in bytes | ||
*/ | ||
fieldNameSize?: number; | ||
|
||
/** | ||
* Max field value size in bytes | ||
*/ | ||
fieldSize?: number; | ||
|
||
/** | ||
* Max number of non-file fields | ||
*/ | ||
fields?: number; | ||
|
||
/** | ||
* For multipart forms, the max file size | ||
*/ | ||
fileSize?: number; | ||
|
||
/** | ||
* Max number of file fields | ||
*/ | ||
files?: number; | ||
|
||
/** | ||
* Max number of header key=>value pairs | ||
*/ | ||
headerPairs?: number; | ||
} | ||
}>; | ||
|
||
export = fastifyMultipart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as fastify from 'fastify' | ||
import * as fastifyMultipart from '../..' | ||
|
||
const app = fastify() | ||
|
||
app.register(fastifyMultipart, { | ||
limits: { | ||
fieldNameSize: 200, | ||
fieldSize: 200, | ||
fields: 200, | ||
fileSize: 200, | ||
files: 2, | ||
headerPairs: 200 | ||
} | ||
}) | ||
|
||
app.get('/path', (request) => { | ||
const isMultiPart = request.isMultipart() | ||
request.multipart((field, file, filename, encoding, mimetype) => { | ||
console.log(field, file, filename, encoding, mimetype, isMultiPart) | ||
}, (err) => { | ||
throw err | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"module": "commonjs", | ||
"noEmit": true, | ||
"strict": true, | ||
}, | ||
"files": [ | ||
"./index.ts" | ||
] | ||
} |