diff --git a/.vscode/settings.json b/.vscode/settings.json index eadb428d..5b821aee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,9 @@ "eslint.run": "onSave", "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, "typescript.tsdk": "node_modules/typescript/lib", "typescript.referencesCodeLens.enabled": true, "files.eol": "\n", diff --git a/package-lock.json b/package-lock.json index 1d001bd2..4a604e8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "typescript": "^5.1.6", - "zod": "^3.21.4" + "zod": "^3.22.4" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -7584,9 +7584,9 @@ } }, "node_modules/zod": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", - "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", + "version": "3.22.4", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz", + "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==", "dev": true, "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/package.json b/package.json index f9231ec3..f2d5fdd3 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,6 @@ "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "typescript": "^5.1.6", - "zod": "^3.21.4" + "zod": "^3.22.4" } } diff --git a/servers/all/$server.ts b/servers/all/$server.ts index 137071b8..9f950b7a 100644 --- a/servers/all/$server.ts +++ b/servers/all/$server.ts @@ -350,7 +350,7 @@ export default (fastify: FastifyInstance, options: FrourioOptions = {}) => { preParsing: hooks_gx3glp.preParsing, preValidation: formatMultipartData([['requiredArr', false], ['optionalArr', true], ['empty', true], ['vals', false], ['files', false]]), }, - methodToHandler(controller_17nfdm3.post.handler), + asyncMethodToHandler(controller_17nfdm3.post.handler), ); fastify.get( diff --git a/servers/all/api/$relay.ts b/servers/all/api/$relay.ts index 1cfe169b..686fd3dc 100644 --- a/servers/all/api/$relay.ts +++ b/servers/all/api/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/500/$relay.ts b/servers/all/api/500/$relay.ts index fec711cc..e7301674 100644 --- a/servers/all/api/500/$relay.ts +++ b/servers/all/api/500/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/empty/$relay.ts b/servers/all/api/empty/$relay.ts index fec711cc..e7301674 100644 --- a/servers/all/api/empty/$relay.ts +++ b/servers/all/api/empty/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/empty/noEmpty/$relay.ts b/servers/all/api/empty/noEmpty/$relay.ts index 1dd6e479..3bb599b1 100644 --- a/servers/all/api/empty/noEmpty/$relay.ts +++ b/servers/all/api/empty/noEmpty/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/multiForm/$relay.ts b/servers/all/api/multiForm/$relay.ts index fec711cc..e7301674 100644 --- a/servers/all/api/multiForm/$relay.ts +++ b/servers/all/api/multiForm/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/multiForm/controller.ts b/servers/all/api/multiForm/controller.ts index 5f0349b9..c1777644 100644 --- a/servers/all/api/multiForm/controller.ts +++ b/servers/all/api/multiForm/controller.ts @@ -15,12 +15,18 @@ export default defineController(() => ({ files: z.array(multipartFileValidator()), }), }, - handler: ({ body }) => ({ - status: 201, - body: Object.entries(body).reduce( - (p, [key, val]) => ({ ...p, [key]: Array.isArray(val) ? val.length : -1 }), - {} as Methods['post']['resBody'] - ), - }), + handler: async ({ body }) => { + const res = { + status: 201 as const, + body: Object.entries(body).reduce( + (p, [key, val]) => ({ ...p, [key]: Array.isArray(val) ? val.length : -1 }), + {} as Methods['post']['resBody'] + ), + }; + + await body.icon.toBuffer(); // for validator test + + return res; + }, }, })); diff --git a/servers/all/api/texts/$relay.ts b/servers/all/api/texts/$relay.ts index fec711cc..e7301674 100644 --- a/servers/all/api/texts/$relay.ts +++ b/servers/all/api/texts/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/texts/_label@string/$relay.ts b/servers/all/api/texts/_label@string/$relay.ts index 5b9a5024..843a7a55 100644 --- a/servers/all/api/texts/_label@string/$relay.ts +++ b/servers/all/api/texts/_label@string/$relay.ts @@ -34,13 +34,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/texts/sample/$relay.ts b/servers/all/api/texts/sample/$relay.ts index 1dd6e479..3bb599b1 100644 --- a/servers/all/api/texts/sample/$relay.ts +++ b/servers/all/api/texts/sample/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/users/$relay.ts b/servers/all/api/users/$relay.ts index 0c49c45b..52b94b5e 100644 --- a/servers/all/api/users/$relay.ts +++ b/servers/all/api/users/$relay.ts @@ -28,13 +28,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/users/_userId@number/$relay.ts b/servers/all/api/users/_userId@number/$relay.ts index 5362aea4..5812078f 100644 --- a/servers/all/api/users/_userId@number/$relay.ts +++ b/servers/all/api/users/_userId@number/$relay.ts @@ -38,13 +38,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/users/_userId@number/_name/$relay.ts b/servers/all/api/users/_userId@number/_name/$relay.ts index 5741a44b..34296d89 100644 --- a/servers/all/api/users/_userId@number/_name/$relay.ts +++ b/servers/all/api/users/_userId@number/_name/$relay.ts @@ -39,13 +39,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/all/api/zod/$relay.ts b/servers/all/api/zod/$relay.ts index fec711cc..e7301674 100644 --- a/servers/all/api/zod/$relay.ts +++ b/servers/all/api/zod/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/minimum/api/$relay.ts b/servers/minimum/api/$relay.ts index 1cfe169b..686fd3dc 100644 --- a/servers/minimum/api/$relay.ts +++ b/servers/minimum/api/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noMulter/api/$relay.ts b/servers/noMulter/api/$relay.ts index 1cfe169b..686fd3dc 100644 --- a/servers/noMulter/api/$relay.ts +++ b/servers/noMulter/api/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noMulter/api/empty/$relay.ts b/servers/noMulter/api/empty/$relay.ts index fec711cc..e7301674 100644 --- a/servers/noMulter/api/empty/$relay.ts +++ b/servers/noMulter/api/empty/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noMulter/api/empty/noEmpty/$relay.ts b/servers/noMulter/api/empty/noEmpty/$relay.ts index 1dd6e479..3bb599b1 100644 --- a/servers/noMulter/api/empty/noEmpty/$relay.ts +++ b/servers/noMulter/api/empty/noEmpty/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noMulter/api/texts/$relay.ts b/servers/noMulter/api/texts/$relay.ts index fec711cc..e7301674 100644 --- a/servers/noMulter/api/texts/$relay.ts +++ b/servers/noMulter/api/texts/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noMulter/api/texts/sample/$relay.ts b/servers/noMulter/api/texts/sample/$relay.ts index 1dd6e479..3bb599b1 100644 --- a/servers/noMulter/api/texts/sample/$relay.ts +++ b/servers/noMulter/api/texts/sample/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noMulter/api/users/$relay.ts b/servers/noMulter/api/users/$relay.ts index 98c01ce0..2ff124f2 100644 --- a/servers/noMulter/api/users/$relay.ts +++ b/servers/noMulter/api/users/$relay.ts @@ -25,13 +25,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noMulter/api/users/_userId@number/$relay.ts b/servers/noMulter/api/users/_userId@number/$relay.ts index 420c8243..0dad67c5 100644 --- a/servers/noMulter/api/users/_userId@number/$relay.ts +++ b/servers/noMulter/api/users/_userId@number/$relay.ts @@ -35,13 +35,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noTypedParams/api/$relay.ts b/servers/noTypedParams/api/$relay.ts index 1cfe169b..686fd3dc 100644 --- a/servers/noTypedParams/api/$relay.ts +++ b/servers/noTypedParams/api/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noTypedParams/api/empty/$relay.ts b/servers/noTypedParams/api/empty/$relay.ts index fec711cc..e7301674 100644 --- a/servers/noTypedParams/api/empty/$relay.ts +++ b/servers/noTypedParams/api/empty/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noTypedParams/api/empty/noEmpty/$relay.ts b/servers/noTypedParams/api/empty/noEmpty/$relay.ts index 1dd6e479..3bb599b1 100644 --- a/servers/noTypedParams/api/empty/noEmpty/$relay.ts +++ b/servers/noTypedParams/api/empty/noEmpty/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noTypedParams/api/multiForm/$relay.ts b/servers/noTypedParams/api/multiForm/$relay.ts index fec711cc..e7301674 100644 --- a/servers/noTypedParams/api/multiForm/$relay.ts +++ b/servers/noTypedParams/api/multiForm/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noTypedParams/api/texts/$relay.ts b/servers/noTypedParams/api/texts/$relay.ts index fec711cc..e7301674 100644 --- a/servers/noTypedParams/api/texts/$relay.ts +++ b/servers/noTypedParams/api/texts/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noTypedParams/api/texts/sample/$relay.ts b/servers/noTypedParams/api/texts/sample/$relay.ts index 1dd6e479..3bb599b1 100644 --- a/servers/noTypedParams/api/texts/sample/$relay.ts +++ b/servers/noTypedParams/api/texts/sample/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noTypedParams/api/users/$relay.ts b/servers/noTypedParams/api/users/$relay.ts index 98c01ce0..2ff124f2 100644 --- a/servers/noTypedParams/api/users/$relay.ts +++ b/servers/noTypedParams/api/users/$relay.ts @@ -25,13 +25,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noValidator/api/$relay.ts b/servers/noValidator/api/$relay.ts index 1cfe169b..686fd3dc 100644 --- a/servers/noValidator/api/$relay.ts +++ b/servers/noValidator/api/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noValidator/api/empty/$relay.ts b/servers/noValidator/api/empty/$relay.ts index fec711cc..e7301674 100644 --- a/servers/noValidator/api/empty/$relay.ts +++ b/servers/noValidator/api/empty/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noValidator/api/empty/noEmpty/$relay.ts b/servers/noValidator/api/empty/noEmpty/$relay.ts index 1dd6e479..3bb599b1 100644 --- a/servers/noValidator/api/empty/noEmpty/$relay.ts +++ b/servers/noValidator/api/empty/noEmpty/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noValidator/api/multiForm/$relay.ts b/servers/noValidator/api/multiForm/$relay.ts index fec711cc..e7301674 100644 --- a/servers/noValidator/api/multiForm/$relay.ts +++ b/servers/noValidator/api/multiForm/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noValidator/api/texts/$relay.ts b/servers/noValidator/api/texts/$relay.ts index fec711cc..e7301674 100644 --- a/servers/noValidator/api/texts/$relay.ts +++ b/servers/noValidator/api/texts/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noValidator/api/texts/sample/$relay.ts b/servers/noValidator/api/texts/sample/$relay.ts index 1dd6e479..3bb599b1 100644 --- a/servers/noValidator/api/texts/sample/$relay.ts +++ b/servers/noValidator/api/texts/sample/$relay.ts @@ -24,13 +24,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noValidator/api/users/$relay.ts b/servers/noValidator/api/users/$relay.ts index 98c01ce0..2ff124f2 100644 --- a/servers/noValidator/api/users/$relay.ts +++ b/servers/noValidator/api/users/$relay.ts @@ -25,13 +25,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/servers/noValidator/api/users/_userId@number/$relay.ts b/servers/noValidator/api/users/_userId@number/$relay.ts index 420c8243..0dad67c5 100644 --- a/servers/noValidator/api/users/_userId@number/$relay.ts +++ b/servers/noValidator/api/users/_userId@number/$relay.ts @@ -35,13 +35,15 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); diff --git a/src/createControllersText.ts b/src/createControllersText.ts index 55b2262c..5110dcdf 100644 --- a/src/createControllersText.ts +++ b/src/createControllersText.ts @@ -122,16 +122,18 @@ export function defineController => - z.object({ - type: z.literal('file'), - toBuffer: z.function().returns(z.promise(z.instanceof(Buffer))), - file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() })), - fieldname: z.string(), - filename: z.string(), - encoding: z.string(), - mimetype: z.string(), - fields: z.record(z.any()), - }); + z + .object({ + type: z.literal('file'), + toBuffer: z.function().returns(z.any()), + file: z.instanceof(Readable).and(z.object({ truncated: z.boolean(), bytesRead: z.number() }).passthrough()), + fieldname: z.string(), + filename: z.string(), + encoding: z.string(), + mimetype: z.string(), + fields: z.record(z.any()), + }) + .passthrough(); `; fs.writeFileSync(