@rosen-bridge/fastify-enhanced 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ dist
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # @rosen-bridge/fastify-enhanced
2
+
3
+ ## Table of contents
4
+
5
+ - [Introduction](#introduction)
6
+ - [Installation](#installation)
7
+ - [Usage](#usage)
8
+
9
+ ## Introduction
10
+
11
+ A wrapper around fastify web framework to make it even better
12
+
13
+ ## Installation
14
+
15
+ npm:
16
+
17
+ ```sh
18
+ npm i @rosen-bridge/fastify-enhanced
19
+ ```
20
+
21
+ yarn:
22
+
23
+ ```sh
24
+ yarn add @rosen-bridge/fastify-enhanced
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ To use the enhanced Fastify, import `createFastify` and use it to create a fastify instance and register routes. Use data types defined under `types` object, to define validation constraints for requests and responses:
30
+
31
+ ```ts
32
+ import {
33
+ ZodTypeProvider,
34
+ createFastify,
35
+ types,
36
+ } from '@rosen-bridge/fastify-enhanced';
37
+ import { FastifyBaseLogger, FastifyInstance } from 'fastify';
38
+ import { IncomingMessage, Server, ServerResponse } from 'http';
39
+
40
+ const addTokenPaymentRoute = (
41
+ fastify: FastifyInstance<
42
+ Server<typeof IncomingMessage, typeof ServerResponse>,
43
+ IncomingMessage,
44
+ ServerResponse<IncomingMessage>,
45
+ FastifyBaseLogger,
46
+ ZodTypeProvider
47
+ >
48
+ ) => {
49
+ const bodySchema = types.object({
50
+ tokenName: types.string(),
51
+ tokenAmount: types.bigint(),
52
+ tokenDecimals: types.number(),
53
+ });
54
+
55
+ const res200Schema = types.object({
56
+ name: types.string(),
57
+ amount: types.bigint(),
58
+ decimal: types.number(),
59
+ });
60
+
61
+ const payTokenOpts = {
62
+ schema: {
63
+ body: bodySchema,
64
+ response: {
65
+ 200: res200Schema,
66
+ },
67
+ },
68
+ };
69
+
70
+ fastify.post('/payToken', payTokenOpts, async (request, reply) => {
71
+ return reply.status(200).send({
72
+ name: request.body.tokenName,
73
+ amount: request.body.tokenAmount,
74
+ decimal: request.body.tokenDecimals,
75
+ });
76
+ });
77
+
78
+ return fastify;
79
+ };
80
+
81
+ const fastify = await createFastify(
82
+ {
83
+ path: '/swagger',
84
+ title: '',
85
+ description: '',
86
+ version: '0.0.1',
87
+ },
88
+ { logger: false }
89
+ );
90
+ addTokenPaymentRoute(fastify);
91
+
92
+ const start = async () => {
93
+ try {
94
+ await fastify.listen({ port: 8000 });
95
+ } catch (err) {
96
+ console.log(err);
97
+ process.exit(1);
98
+ }
99
+ };
100
+ start();
101
+ ```
102
+
103
+ To define a nested route don't forget to add `ZodTypeProvider` to the Fastify instance that is passed to the `register` method, to enable Zod typing validation:
104
+
105
+ ```ts
106
+ fastify.register(
107
+ (instance, opts, next) => {
108
+ const subFastify = instance.withTypeProvider<ZodTypeProvider>();
109
+ addTokenPaymentRoute(subFastify);
110
+ next();
111
+ },
112
+ { prefix: 'subroute' }
113
+ );
114
+ ```
@@ -0,0 +1,456 @@
1
+ import zod from 'zod';
2
+ export declare const types: {
3
+ bigint: () => zod.ZodPipeline<
4
+ zod.ZodUnion<[zod.ZodNumber, zod.ZodBigInt]>,
5
+ zod.ZodBigInt
6
+ >;
7
+ string: (
8
+ params?:
9
+ | ({
10
+ errorMap?: zod.ZodErrorMap | undefined;
11
+ invalid_type_error?: string | undefined;
12
+ required_error?: string | undefined;
13
+ description?: string | undefined;
14
+ } & {
15
+ coerce?: true | undefined;
16
+ })
17
+ | undefined
18
+ ) => zod.ZodString;
19
+ number: (
20
+ params?:
21
+ | ({
22
+ errorMap?: zod.ZodErrorMap | undefined;
23
+ invalid_type_error?: string | undefined;
24
+ required_error?: string | undefined;
25
+ description?: string | undefined;
26
+ } & {
27
+ coerce?: boolean | undefined;
28
+ })
29
+ | undefined
30
+ ) => zod.ZodNumber;
31
+ boolean: (
32
+ params?:
33
+ | ({
34
+ errorMap?: zod.ZodErrorMap | undefined;
35
+ invalid_type_error?: string | undefined;
36
+ required_error?: string | undefined;
37
+ description?: string | undefined;
38
+ } & {
39
+ coerce?: boolean | undefined;
40
+ })
41
+ | undefined
42
+ ) => zod.ZodBoolean;
43
+ symbol: (params?: zod.RawCreateParams) => zod.ZodSymbol;
44
+ undefined: (params?: zod.RawCreateParams) => zod.ZodUndefined;
45
+ object: <T extends zod.ZodRawShape>(
46
+ shape: T,
47
+ params?: zod.RawCreateParams
48
+ ) => zod.ZodObject<
49
+ T,
50
+ 'strip',
51
+ zod.ZodTypeAny,
52
+ {
53
+ [k_1 in keyof zod.objectUtil.addQuestionMarks<
54
+ zod.baseObjectOutputType<T>,
55
+ {
56
+ [k in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k]
57
+ ? never
58
+ : k;
59
+ }[keyof T]
60
+ >]: zod.objectUtil.addQuestionMarks<
61
+ zod.baseObjectOutputType<T>,
62
+ {
63
+ [k_2 in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k_2]
64
+ ? never
65
+ : k_2;
66
+ }[keyof T]
67
+ >[k_1];
68
+ },
69
+ {
70
+ [k_2 in keyof zod.baseObjectInputType<T>]: zod.baseObjectInputType<T>[k_2];
71
+ }
72
+ >;
73
+ function: typeof zod.ZodFunction.create;
74
+ z: typeof zod.z;
75
+ setErrorMap: typeof zod.setErrorMap;
76
+ getErrorMap: typeof zod.getErrorMap;
77
+ defaultErrorMap: zod.ZodErrorMap;
78
+ addIssueToContext: typeof zod.addIssueToContext;
79
+ makeIssue: (params: {
80
+ data: any;
81
+ path: (string | number)[];
82
+ errorMaps: zod.ZodErrorMap[];
83
+ issueData: zod.IssueData;
84
+ }) => zod.ZodIssue;
85
+ EMPTY_PATH: zod.ParsePath;
86
+ ParseStatus: typeof zod.ParseStatus;
87
+ INVALID: zod.INVALID;
88
+ DIRTY: <T_1>(value: T_1) => zod.DIRTY<T_1>;
89
+ OK: <T_2>(value: T_2) => zod.OK<T_2>;
90
+ isAborted: (x: zod.ParseReturnType<any>) => x is zod.INVALID;
91
+ isDirty: <T_3>(
92
+ x: zod.ParseReturnType<T_3>
93
+ ) => x is zod.OK<T_3> | zod.DIRTY<T_3>;
94
+ isValid: <T_4>(
95
+ x: zod.ParseReturnType<T_4>
96
+ ) => x is zod.OK<T_4> | zod.DIRTY<T_4>;
97
+ isAsync: <T_5>(
98
+ x: zod.ParseReturnType<T_5>
99
+ ) => x is zod.AsyncParseReturnType<T_5>;
100
+ util: typeof zod.util;
101
+ objectUtil: typeof zod.objectUtil;
102
+ ZodParsedType: {
103
+ function: 'function';
104
+ number: 'number';
105
+ string: 'string';
106
+ nan: 'nan';
107
+ integer: 'integer';
108
+ float: 'float';
109
+ boolean: 'boolean';
110
+ date: 'date';
111
+ bigint: 'bigint';
112
+ symbol: 'symbol';
113
+ undefined: 'undefined';
114
+ null: 'null';
115
+ array: 'array';
116
+ object: 'object';
117
+ unknown: 'unknown';
118
+ promise: 'promise';
119
+ void: 'void';
120
+ never: 'never';
121
+ map: 'map';
122
+ set: 'set';
123
+ };
124
+ getParsedType: (
125
+ data: any
126
+ ) =>
127
+ | 'string'
128
+ | 'number'
129
+ | 'bigint'
130
+ | 'boolean'
131
+ | 'symbol'
132
+ | 'undefined'
133
+ | 'object'
134
+ | 'function'
135
+ | 'array'
136
+ | 'date'
137
+ | 'map'
138
+ | 'nan'
139
+ | 'never'
140
+ | 'null'
141
+ | 'promise'
142
+ | 'set'
143
+ | 'unknown'
144
+ | 'void'
145
+ | 'integer'
146
+ | 'float';
147
+ ZodType: typeof zod.ZodType;
148
+ ZodString: typeof zod.ZodString;
149
+ ZodNumber: typeof zod.ZodNumber;
150
+ ZodBigInt: typeof zod.ZodBigInt;
151
+ ZodBoolean: typeof zod.ZodBoolean;
152
+ ZodDate: typeof zod.ZodDate;
153
+ ZodSymbol: typeof zod.ZodSymbol;
154
+ ZodUndefined: typeof zod.ZodUndefined;
155
+ ZodNull: typeof zod.ZodNull;
156
+ ZodAny: typeof zod.ZodAny;
157
+ ZodUnknown: typeof zod.ZodUnknown;
158
+ ZodNever: typeof zod.ZodNever;
159
+ ZodVoid: typeof zod.ZodVoid;
160
+ ZodArray: typeof zod.ZodArray;
161
+ ZodObject: typeof zod.ZodObject;
162
+ ZodUnion: typeof zod.ZodUnion;
163
+ ZodDiscriminatedUnion: typeof zod.ZodDiscriminatedUnion;
164
+ ZodIntersection: typeof zod.ZodIntersection;
165
+ ZodTuple: typeof zod.ZodTuple;
166
+ ZodRecord: typeof zod.ZodRecord;
167
+ ZodMap: typeof zod.ZodMap;
168
+ ZodSet: typeof zod.ZodSet;
169
+ ZodFunction: typeof zod.ZodFunction;
170
+ ZodLazy: typeof zod.ZodLazy;
171
+ ZodLiteral: typeof zod.ZodLiteral;
172
+ ZodEnum: typeof zod.ZodEnum;
173
+ ZodNativeEnum: typeof zod.ZodNativeEnum;
174
+ ZodPromise: typeof zod.ZodPromise;
175
+ ZodEffects: typeof zod.ZodEffects;
176
+ ZodTransformer: typeof zod.ZodEffects;
177
+ ZodOptional: typeof zod.ZodOptional;
178
+ ZodNullable: typeof zod.ZodNullable;
179
+ ZodDefault: typeof zod.ZodDefault;
180
+ ZodCatch: typeof zod.ZodCatch;
181
+ ZodNaN: typeof zod.ZodNaN;
182
+ BRAND: typeof zod.BRAND;
183
+ ZodBranded: typeof zod.ZodBranded;
184
+ ZodPipeline: typeof zod.ZodPipeline;
185
+ ZodReadonly: typeof zod.ZodReadonly;
186
+ custom: <T_6>(
187
+ check?: ((data: unknown) => any) | undefined,
188
+ params?:
189
+ | string
190
+ | (Partial<zod.util.Omit<zod.ZodCustomIssue, 'code'>> & {
191
+ fatal?: boolean | undefined;
192
+ })
193
+ | ((input: any) => Partial<zod.util.Omit<zod.ZodCustomIssue, 'code'>> & {
194
+ fatal?: boolean | undefined;
195
+ })
196
+ | undefined,
197
+ fatal?: boolean | undefined
198
+ ) => zod.ZodType<T_6, zod.ZodTypeDef, T_6>;
199
+ Schema: typeof zod.ZodType;
200
+ ZodSchema: typeof zod.ZodType;
201
+ late: {
202
+ object: <T_7 extends zod.ZodRawShape>(
203
+ shape: () => T_7,
204
+ params?: zod.RawCreateParams
205
+ ) => zod.ZodObject<
206
+ T_7,
207
+ 'strip',
208
+ zod.ZodTypeAny,
209
+ {
210
+ [k_1_1 in keyof zod.objectUtil.addQuestionMarks<
211
+ zod.baseObjectOutputType<T_7>,
212
+ {
213
+ [k_3 in keyof zod.baseObjectOutputType<T_7>]: undefined extends zod.baseObjectOutputType<T_7>[k_3]
214
+ ? never
215
+ : k_3;
216
+ }[keyof T_7]
217
+ >]: zod.objectUtil.addQuestionMarks<
218
+ zod.baseObjectOutputType<T_7>,
219
+ {
220
+ [k_4 in keyof zod.baseObjectOutputType<T_7>]: undefined extends zod.baseObjectOutputType<T_7>[k_4]
221
+ ? never
222
+ : k_4;
223
+ }[keyof T_7]
224
+ >[k_1_1];
225
+ },
226
+ {
227
+ [k_2_1 in keyof zod.baseObjectInputType<T_7>]: zod.baseObjectInputType<T_7>[k_2_1];
228
+ }
229
+ >;
230
+ };
231
+ ZodFirstPartyTypeKind: typeof zod.ZodFirstPartyTypeKind;
232
+ coerce: {
233
+ string: (
234
+ params?:
235
+ | ({
236
+ errorMap?: zod.ZodErrorMap | undefined;
237
+ invalid_type_error?: string | undefined;
238
+ required_error?: string | undefined;
239
+ description?: string | undefined;
240
+ } & {
241
+ coerce?: true | undefined;
242
+ })
243
+ | undefined
244
+ ) => zod.ZodString;
245
+ number: (
246
+ params?:
247
+ | ({
248
+ errorMap?: zod.ZodErrorMap | undefined;
249
+ invalid_type_error?: string | undefined;
250
+ required_error?: string | undefined;
251
+ description?: string | undefined;
252
+ } & {
253
+ coerce?: boolean | undefined;
254
+ })
255
+ | undefined
256
+ ) => zod.ZodNumber;
257
+ boolean: (
258
+ params?:
259
+ | ({
260
+ errorMap?: zod.ZodErrorMap | undefined;
261
+ invalid_type_error?: string | undefined;
262
+ required_error?: string | undefined;
263
+ description?: string | undefined;
264
+ } & {
265
+ coerce?: boolean | undefined;
266
+ })
267
+ | undefined
268
+ ) => zod.ZodBoolean;
269
+ bigint: (
270
+ params?:
271
+ | ({
272
+ errorMap?: zod.ZodErrorMap | undefined;
273
+ invalid_type_error?: string | undefined;
274
+ required_error?: string | undefined;
275
+ description?: string | undefined;
276
+ } & {
277
+ coerce?: boolean | undefined;
278
+ })
279
+ | undefined
280
+ ) => zod.ZodBigInt;
281
+ date: (
282
+ params?:
283
+ | ({
284
+ errorMap?: zod.ZodErrorMap | undefined;
285
+ invalid_type_error?: string | undefined;
286
+ required_error?: string | undefined;
287
+ description?: string | undefined;
288
+ } & {
289
+ coerce?: boolean | undefined;
290
+ })
291
+ | undefined
292
+ ) => zod.ZodDate;
293
+ };
294
+ any: (params?: zod.RawCreateParams) => zod.ZodAny;
295
+ array: <T_8 extends zod.ZodTypeAny>(
296
+ schema: T_8,
297
+ params?: zod.RawCreateParams
298
+ ) => zod.ZodArray<T_8, 'many'>;
299
+ date: (
300
+ params?:
301
+ | ({
302
+ errorMap?: zod.ZodErrorMap | undefined;
303
+ invalid_type_error?: string | undefined;
304
+ required_error?: string | undefined;
305
+ description?: string | undefined;
306
+ } & {
307
+ coerce?: boolean | undefined;
308
+ })
309
+ | undefined
310
+ ) => zod.ZodDate;
311
+ discriminatedUnion: typeof zod.ZodDiscriminatedUnion.create;
312
+ effect: <I extends zod.ZodTypeAny>(
313
+ schema: I,
314
+ effect: zod.Effect<I['_output']>,
315
+ params?: zod.RawCreateParams
316
+ ) => zod.ZodEffects<I, I['_output'], zod.input<I>>;
317
+ enum: {
318
+ <U extends string, T_9 extends readonly [U, ...U[]]>(
319
+ values: T_9,
320
+ params?: zod.RawCreateParams
321
+ ): zod.ZodEnum<zod.Writeable<T_9>>;
322
+ <U_1 extends string, T_10 extends [U_1, ...U_1[]]>(
323
+ values: T_10,
324
+ params?: zod.RawCreateParams
325
+ ): zod.ZodEnum<T_10>;
326
+ };
327
+ instanceof: <T_11 extends abstract new (..._: any[]) => {}>(
328
+ cls: T_11,
329
+ params?:
330
+ | (Partial<zod.util.Omit<zod.ZodCustomIssue, 'code'>> & {
331
+ fatal?: boolean | undefined;
332
+ })
333
+ | undefined
334
+ ) => zod.ZodType<InstanceType<T_11>, zod.ZodTypeDef, InstanceType<T_11>>;
335
+ intersection: <T_12 extends zod.ZodTypeAny, U_2 extends zod.ZodTypeAny>(
336
+ left: T_12,
337
+ right: U_2,
338
+ params?: zod.RawCreateParams
339
+ ) => zod.ZodIntersection<T_12, U_2>;
340
+ lazy: <T_13 extends zod.ZodTypeAny>(
341
+ getter: () => T_13,
342
+ params?: zod.RawCreateParams
343
+ ) => zod.ZodLazy<T_13>;
344
+ literal: <T_14 extends zod.Primitive>(
345
+ value: T_14,
346
+ params?: zod.RawCreateParams
347
+ ) => zod.ZodLiteral<T_14>;
348
+ map: <
349
+ Key extends zod.ZodTypeAny = zod.ZodTypeAny,
350
+ Value extends zod.ZodTypeAny = zod.ZodTypeAny
351
+ >(
352
+ keyType: Key,
353
+ valueType: Value,
354
+ params?: zod.RawCreateParams
355
+ ) => zod.ZodMap<Key, Value>;
356
+ nan: (params?: zod.RawCreateParams) => zod.ZodNaN;
357
+ nativeEnum: <T_15 extends zod.EnumLike>(
358
+ values: T_15,
359
+ params?: zod.RawCreateParams
360
+ ) => zod.ZodNativeEnum<T_15>;
361
+ never: (params?: zod.RawCreateParams) => zod.ZodNever;
362
+ null: (params?: zod.RawCreateParams) => zod.ZodNull;
363
+ nullable: <T_16 extends zod.ZodTypeAny>(
364
+ type: T_16,
365
+ params?: zod.RawCreateParams
366
+ ) => zod.ZodNullable<T_16>;
367
+ oboolean: () => zod.ZodOptional<zod.ZodBoolean>;
368
+ onumber: () => zod.ZodOptional<zod.ZodNumber>;
369
+ optional: <T_17 extends zod.ZodTypeAny>(
370
+ type: T_17,
371
+ params?: zod.RawCreateParams
372
+ ) => zod.ZodOptional<T_17>;
373
+ ostring: () => zod.ZodOptional<zod.ZodString>;
374
+ pipeline: typeof zod.ZodPipeline.create;
375
+ preprocess: <I_1 extends zod.ZodTypeAny>(
376
+ preprocess: (arg: unknown, ctx: zod.RefinementCtx) => unknown,
377
+ schema: I_1,
378
+ params?: zod.RawCreateParams
379
+ ) => zod.ZodEffects<I_1, I_1['_output'], unknown>;
380
+ promise: <T_18 extends zod.ZodTypeAny>(
381
+ schema: T_18,
382
+ params?: zod.RawCreateParams
383
+ ) => zod.ZodPromise<T_18>;
384
+ record: typeof zod.ZodRecord.create;
385
+ set: <Value_1 extends zod.ZodTypeAny = zod.ZodTypeAny>(
386
+ valueType: Value_1,
387
+ params?: zod.RawCreateParams
388
+ ) => zod.ZodSet<Value_1>;
389
+ strictObject: <T_19 extends zod.ZodRawShape>(
390
+ shape: T_19,
391
+ params?: zod.RawCreateParams
392
+ ) => zod.ZodObject<
393
+ T_19,
394
+ 'strict',
395
+ zod.ZodTypeAny,
396
+ {
397
+ [k_1_2 in keyof zod.objectUtil.addQuestionMarks<
398
+ zod.baseObjectOutputType<T_19>,
399
+ {
400
+ [k_5 in keyof zod.baseObjectOutputType<T_19>]: undefined extends zod.baseObjectOutputType<T_19>[k_5]
401
+ ? never
402
+ : k_5;
403
+ }[keyof T_19]
404
+ >]: zod.objectUtil.addQuestionMarks<
405
+ zod.baseObjectOutputType<T_19>,
406
+ {
407
+ [k_6 in keyof zod.baseObjectOutputType<T_19>]: undefined extends zod.baseObjectOutputType<T_19>[k_6]
408
+ ? never
409
+ : k_6;
410
+ }[keyof T_19]
411
+ >[k_1_2];
412
+ },
413
+ {
414
+ [k_2_2 in keyof zod.baseObjectInputType<T_19>]: zod.baseObjectInputType<T_19>[k_2_2];
415
+ }
416
+ >;
417
+ transformer: <I extends zod.ZodTypeAny>(
418
+ schema: I,
419
+ effect: zod.Effect<I['_output']>,
420
+ params?: zod.RawCreateParams
421
+ ) => zod.ZodEffects<I, I['_output'], zod.input<I>>;
422
+ tuple: <T_20 extends [] | [zod.ZodTypeAny, ...zod.ZodTypeAny[]]>(
423
+ schemas: T_20,
424
+ params?: zod.RawCreateParams
425
+ ) => zod.ZodTuple<T_20, null>;
426
+ union: <
427
+ T_21 extends readonly [zod.ZodTypeAny, zod.ZodTypeAny, ...zod.ZodTypeAny[]]
428
+ >(
429
+ types: T_21,
430
+ params?: zod.RawCreateParams
431
+ ) => zod.ZodUnion<T_21>;
432
+ unknown: (params?: zod.RawCreateParams) => zod.ZodUnknown;
433
+ void: (params?: zod.RawCreateParams) => zod.ZodVoid;
434
+ NEVER: never;
435
+ ZodIssueCode: {
436
+ invalid_type: 'invalid_type';
437
+ invalid_literal: 'invalid_literal';
438
+ custom: 'custom';
439
+ invalid_union: 'invalid_union';
440
+ invalid_union_discriminator: 'invalid_union_discriminator';
441
+ invalid_enum_value: 'invalid_enum_value';
442
+ unrecognized_keys: 'unrecognized_keys';
443
+ invalid_arguments: 'invalid_arguments';
444
+ invalid_return_type: 'invalid_return_type';
445
+ invalid_date: 'invalid_date';
446
+ invalid_string: 'invalid_string';
447
+ too_small: 'too_small';
448
+ too_big: 'too_big';
449
+ invalid_intersection_types: 'invalid_intersection_types';
450
+ not_multiple_of: 'not_multiple_of';
451
+ not_finite: 'not_finite';
452
+ };
453
+ quotelessJson: (obj: any) => string;
454
+ ZodError: typeof zod.ZodError;
455
+ };
456
+ //# sourceMappingURL=dataTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataTypes.d.ts","sourceRoot":"","sources":["../lib/dataTypes.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import zod from 'zod';
2
+ export const types = {
3
+ ...zod,
4
+ bigint: () =>
5
+ zod.union([zod.number(), zod.bigint()]).pipe(zod.coerce.bigint()),
6
+ };
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YVR5cGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vbGliL2RhdGFUeXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEdBQUcsTUFBTSxLQUFLLENBQUM7QUFFdEIsTUFBTSxDQUFDLE1BQU0sS0FBSyxHQUFHO0lBQ25CLEdBQUksR0FBa0M7SUFDdEMsTUFBTSxFQUFFLEdBQUcsRUFBRSxDQUNYLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLEVBQUUsR0FBRyxDQUFDLE1BQU0sRUFBRSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLE1BQU0sQ0FBQyxNQUFNLEVBQUUsQ0FBQztDQUNwRSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHpvZCBmcm9tICd6b2QnO1xuXG5leHBvcnQgY29uc3QgdHlwZXMgPSB7XG4gIC4uLih6b2QgYXMgT21pdDx0eXBlb2Ygem9kLCAnYmlnaW50Jz4pLFxuICBiaWdpbnQ6ICgpID0+XG4gICAgem9kLnVuaW9uKFt6b2QubnVtYmVyKCksIHpvZC5iaWdpbnQoKV0pLnBpcGUoem9kLmNvZXJjZS5iaWdpbnQoKSksXG59O1xuIl19
@@ -0,0 +1,46 @@
1
+ import { FastifyWithZod, SwaggerOpts } from './types';
2
+ /**
3
+ * creates an instance of Fastify with Zod validation library as validator and
4
+ * type provider
5
+ *
6
+ * @param {string} [swaggerPath='/swagger']
7
+ * @param {boolean} [jsonHandler=JsonBigIntFactory({
8
+ * alwaysParseAsBig: false,
9
+ * useNativeBigInt: true,
10
+ * })]
11
+ * @param {*} [opts={ logger: true }]
12
+ * @return {Promise<
13
+ * FastifyInstance<
14
+ * http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>,
15
+ * http.IncomingMessage,
16
+ * http.ServerResponse<http.IncomingMessage>,
17
+ * FastifyBaseLogger,
18
+ * ZodTypeProvider
19
+ * >
20
+ * >}
21
+ */
22
+ export declare const createFastify: (
23
+ swaggerOpts?: SwaggerOpts,
24
+ opts?: {
25
+ logger: boolean;
26
+ },
27
+ jsonHandler?: {
28
+ parse: (
29
+ text: string,
30
+ reviver?: ((this: any, key: string, value: any) => any) | undefined
31
+ ) => any;
32
+ stringify: {
33
+ (
34
+ value: any,
35
+ replacer?: ((this: any, key: string, value: any) => any) | undefined,
36
+ space?: string | number | undefined
37
+ ): string;
38
+ (
39
+ value: any,
40
+ replacer?: (string | number)[] | null | undefined,
41
+ space?: string | number | undefined
42
+ ): string;
43
+ };
44
+ }
45
+ ) => Promise<FastifyWithZod>;
46
+ //# sourceMappingURL=fastify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../lib/fastify.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,iBACX,WAAW;;;;;;;;MAWvB,QAAQ,cAAc,CA8BxB,CAAC"}