forked from FlameWolf/formzilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
42 lines (40 loc) · 1.2 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Readable } from "stream";
import { FileInfo, Limits } from "busboy";
import { FastifyPluginOptions, FastifyPluginAsync } from "fastify";
export interface Dictionary extends Object {
[key: string | symbol]: any;
}
export interface File {
field: string | undefined;
originalName: string;
encoding: string;
mimeType: string;
path: string | undefined;
stream: Readable | undefined;
data: Buffer | undefined;
error: Error | undefined;
}
export type FileHandler = (name: string, stream: Readable, info: FileInfo) => File | Promise<File>;
export interface StorageOption {
process: FileHandler;
}
export interface FileSaveTarget {
directory?: string;
fileName?: string;
}
export type TargetType = FileSaveTarget | ((source: File) => FileSaveTarget);
export interface FormDataParserPluginOptions extends FastifyPluginOptions {
limits?: Limits;
storage?: StorageOption;
}
export type FormDataParserPlugin = FastifyPluginAsync<FormDataParserPluginOptions> & Dictionary;
export interface FieldParser {
parseField(name: string, value: any): any;
}
declare module "fastify" {
interface FastifyRequest {
__files__?: Array<File>;
}
}
declare const formDataParser: FormDataParserPlugin;
export default formDataParser;