Skip to content

Commit

Permalink
fix typescript build error when using file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdean-digicatapult committed Aug 21, 2024
1 parent d573d6f commit 01633e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
14 changes: 10 additions & 4 deletions packages/cli/src/routeGeneration/templates/express.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,16 @@ export function RegisterRoutes(app: Router) {
authenticateMiddleware({{json security}}),
{{/if}}
{{#if uploadFile}}
upload.fields({{json uploadFileName}}),
{{/if}}
{{#if uploadFiles}}
upload.array('{{uploadFilesName}}'),
upload.fields([
{{#each uploadFileName}}
{
name: {{json name}},
{{#if maxCount}}
maxCount: {{maxCount}}
{{/if}}
}{{#if @last}}{{else}},{{/if}}
{{/each}}
]),
{{/if}}
...(fetchMiddlewares<RequestHandler>({{../name}})),
...(fetchMiddlewares<RequestHandler>({{../name}}.prototype.{{name}})),
Expand Down
7 changes: 0 additions & 7 deletions packages/cli/src/routeGeneration/templates/hapi.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ export function RegisterRoutes(server: any) {
multipart: true,
allow: 'multipart/form-data'
},
{{else if uploadFiles}}
payload: {
output: 'stream',
parse: true,
multipart: true,
allow: 'multipart/form-data'
},
{{/if}}
handler: {{#if ../../iocModule}}async {{/if}}function {{../name}}_{{name}}(request: Request, h: ResponseToolkit) {
const args: Record<string, TsoaRoute.ParameterSchema> = {
Expand Down
14 changes: 10 additions & 4 deletions packages/cli/src/routeGeneration/templates/koa.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,16 @@ export function RegisterRoutes(router: KoaRouter) {
authenticateMiddleware({{json security}}),
{{/if}}
{{#if uploadFile}}
upload.fields({{json uploadFileName}}),
{{/if}}
{{#if uploadFiles}}
upload.array('{{uploadFilesName}}'),
upload.fields([
{{#each uploadFileName}}
{
name: {{json name}},
{{#if maxCount}}
maxCount: {{maxCount}}
{{/if}}
}{{#if @last}}{{else}},{{/if}}
{{/each}}
]),
{{/if}}
...(fetchMiddlewares<Middleware>({{../name}})),
...(fetchMiddlewares<Middleware>({{../name}}.prototype.{{name}})),
Expand Down

0 comments on commit 01633e1

Please sign in to comment.