@tsoa-next/cli 7.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.
Files changed (122) hide show
  1. package/README.MD +3 -0
  2. package/dist/cli.d.ts +44 -0
  3. package/dist/cli.js +356 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/index.d.ts +6 -0
  6. package/dist/index.js +25 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/metadataGeneration/controllerGenerator.d.ts +30 -0
  9. package/dist/metadataGeneration/controllerGenerator.js +229 -0
  10. package/dist/metadataGeneration/controllerGenerator.js.map +1 -0
  11. package/dist/metadataGeneration/exceptions.d.ts +13 -0
  12. package/dist/metadataGeneration/exceptions.js +53 -0
  13. package/dist/metadataGeneration/exceptions.js.map +1 -0
  14. package/dist/metadataGeneration/extension.d.ts +5 -0
  15. package/dist/metadataGeneration/extension.js +85 -0
  16. package/dist/metadataGeneration/extension.js.map +1 -0
  17. package/dist/metadataGeneration/initializer-value.d.ts +6 -0
  18. package/dist/metadataGeneration/initializer-value.js +154 -0
  19. package/dist/metadataGeneration/initializer-value.js.map +1 -0
  20. package/dist/metadataGeneration/metadataGenerator.d.ts +29 -0
  21. package/dist/metadataGeneration/metadataGenerator.js +220 -0
  22. package/dist/metadataGeneration/metadataGenerator.js.map +1 -0
  23. package/dist/metadataGeneration/methodGenerator.d.ts +45 -0
  24. package/dist/metadataGeneration/methodGenerator.js +367 -0
  25. package/dist/metadataGeneration/methodGenerator.js.map +1 -0
  26. package/dist/metadataGeneration/parameterGenerator.d.ts +33 -0
  27. package/dist/metadataGeneration/parameterGenerator.js +552 -0
  28. package/dist/metadataGeneration/parameterGenerator.js.map +1 -0
  29. package/dist/metadataGeneration/transformer/dateTransformer.d.ts +6 -0
  30. package/dist/metadataGeneration/transformer/dateTransformer.js +28 -0
  31. package/dist/metadataGeneration/transformer/dateTransformer.js.map +1 -0
  32. package/dist/metadataGeneration/transformer/enumTransformer.d.ts +12 -0
  33. package/dist/metadataGeneration/transformer/enumTransformer.js +75 -0
  34. package/dist/metadataGeneration/transformer/enumTransformer.js.map +1 -0
  35. package/dist/metadataGeneration/transformer/primitiveTransformer.d.ts +11 -0
  36. package/dist/metadataGeneration/transformer/primitiveTransformer.js +70 -0
  37. package/dist/metadataGeneration/transformer/primitiveTransformer.js.map +1 -0
  38. package/dist/metadataGeneration/transformer/propertyTransformer.d.ts +12 -0
  39. package/dist/metadataGeneration/transformer/propertyTransformer.js +101 -0
  40. package/dist/metadataGeneration/transformer/propertyTransformer.js.map +1 -0
  41. package/dist/metadataGeneration/transformer/referenceTransformer.d.ts +10 -0
  42. package/dist/metadataGeneration/transformer/referenceTransformer.js +81 -0
  43. package/dist/metadataGeneration/transformer/referenceTransformer.js.map +1 -0
  44. package/dist/metadataGeneration/transformer/transformer.d.ts +9 -0
  45. package/dist/metadataGeneration/transformer/transformer.js +39 -0
  46. package/dist/metadataGeneration/transformer/transformer.js.map +1 -0
  47. package/dist/metadataGeneration/typeResolver.d.ts +52 -0
  48. package/dist/metadataGeneration/typeResolver.js +1202 -0
  49. package/dist/metadataGeneration/typeResolver.js.map +1 -0
  50. package/dist/module/generate-routes.d.ts +9 -0
  51. package/dist/module/generate-routes.js +90 -0
  52. package/dist/module/generate-routes.js.map +1 -0
  53. package/dist/module/generate-spec.d.ts +9 -0
  54. package/dist/module/generate-spec.js +79 -0
  55. package/dist/module/generate-spec.js.map +1 -0
  56. package/dist/routeGeneration/defaultRouteGenerator.d.ts +12 -0
  57. package/dist/routeGeneration/defaultRouteGenerator.js +119 -0
  58. package/dist/routeGeneration/defaultRouteGenerator.js.map +1 -0
  59. package/dist/routeGeneration/routeGenerator.d.ts +56 -0
  60. package/dist/routeGeneration/routeGenerator.js +257 -0
  61. package/dist/routeGeneration/routeGenerator.js.map +1 -0
  62. package/dist/routeGeneration/templates/express.hbs +221 -0
  63. package/dist/routeGeneration/templates/hapi.hbs +267 -0
  64. package/dist/routeGeneration/templates/koa.hbs +218 -0
  65. package/dist/swagger/specGenerator.d.ts +33 -0
  66. package/dist/swagger/specGenerator.js +253 -0
  67. package/dist/swagger/specGenerator.js.map +1 -0
  68. package/dist/swagger/specGenerator2.d.ts +27 -0
  69. package/dist/swagger/specGenerator2.js +476 -0
  70. package/dist/swagger/specGenerator2.js.map +1 -0
  71. package/dist/swagger/specGenerator3.d.ts +158 -0
  72. package/dist/swagger/specGenerator3.js +646 -0
  73. package/dist/swagger/specGenerator3.js.map +1 -0
  74. package/dist/swagger/specGenerator31.d.ts +24 -0
  75. package/dist/swagger/specGenerator31.js +75 -0
  76. package/dist/swagger/specGenerator31.js.map +1 -0
  77. package/dist/utils/decoratorUtils.d.ts +9 -0
  78. package/dist/utils/decoratorUtils.js +118 -0
  79. package/dist/utils/decoratorUtils.js.map +1 -0
  80. package/dist/utils/flowUtils.d.ts +1 -0
  81. package/dist/utils/flowUtils.js +8 -0
  82. package/dist/utils/flowUtils.js.map +1 -0
  83. package/dist/utils/fs.d.ts +5 -0
  84. package/dist/utils/fs.js +55 -0
  85. package/dist/utils/fs.js.map +1 -0
  86. package/dist/utils/genericTypeGuards.d.ts +1 -0
  87. package/dist/utils/genericTypeGuards.js +8 -0
  88. package/dist/utils/genericTypeGuards.js.map +1 -0
  89. package/dist/utils/headerTypeHelpers.d.ts +5 -0
  90. package/dist/utils/headerTypeHelpers.js +27 -0
  91. package/dist/utils/headerTypeHelpers.js.map +1 -0
  92. package/dist/utils/importClassesFromDirectories.d.ts +4 -0
  93. package/dist/utils/importClassesFromDirectories.js +20 -0
  94. package/dist/utils/importClassesFromDirectories.js.map +1 -0
  95. package/dist/utils/internalTypeGuards.d.ts +5 -0
  96. package/dist/utils/internalTypeGuards.js +66 -0
  97. package/dist/utils/internalTypeGuards.js.map +1 -0
  98. package/dist/utils/isVoidType.d.ts +2 -0
  99. package/dist/utils/isVoidType.js +16 -0
  100. package/dist/utils/isVoidType.js.map +1 -0
  101. package/dist/utils/jsDocUtils.d.ts +8 -0
  102. package/dist/utils/jsDocUtils.js +122 -0
  103. package/dist/utils/jsDocUtils.js.map +1 -0
  104. package/dist/utils/jsonUtils.d.ts +1 -0
  105. package/dist/utils/jsonUtils.js +12 -0
  106. package/dist/utils/jsonUtils.js.map +1 -0
  107. package/dist/utils/pathUtils.d.ts +9 -0
  108. package/dist/utils/pathUtils.js +37 -0
  109. package/dist/utils/pathUtils.js.map +1 -0
  110. package/dist/utils/specMerge.d.ts +2 -0
  111. package/dist/utils/specMerge.js +36 -0
  112. package/dist/utils/specMerge.js.map +1 -0
  113. package/dist/utils/swaggerUtils.d.ts +3 -0
  114. package/dist/utils/swaggerUtils.js +22 -0
  115. package/dist/utils/swaggerUtils.js.map +1 -0
  116. package/dist/utils/unspecifiedObject.d.ts +3 -0
  117. package/dist/utils/unspecifiedObject.js +3 -0
  118. package/dist/utils/unspecifiedObject.js.map +1 -0
  119. package/dist/utils/validatorUtils.d.ts +5 -0
  120. package/dist/utils/validatorUtils.js +241 -0
  121. package/dist/utils/validatorUtils.js.map +1 -0
  122. package/package.json +69 -0
@@ -0,0 +1,267 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
4
+ import type { TsoaRoute } from '@tsoa-next/runtime';
5
+ import { fetchMiddlewares, HapiTemplateService } from '@tsoa-next/runtime';
6
+ {{#each controllers}}
7
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
8
+ import { {{name}} } from '{{modulePath}}';
9
+ {{/each}}
10
+ {{#if authenticationModule}}
11
+ import { hapiAuthentication } from '{{authenticationModule}}';
12
+ // @ts-ignore - no great way to install types from subpackage
13
+ {{/if}}
14
+ {{#if iocModule}}
15
+ import { iocContainer } from '{{iocModule}}';
16
+ import type { IocContainer, IocContainerFactory } from '@tsoa-next/runtime';
17
+ {{/if}}
18
+ import { boomify, isBoom, type Payload } from '@hapi/boom';
19
+ import type { Request, ResponseToolkit, RouteOptionsPreAllOptions } from '@hapi/hapi';
20
+
21
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
22
+
23
+ const models: TsoaRoute.Models = {
24
+ {{#each models}}
25
+ "{{@key}}": {
26
+ {{#if enums}}
27
+ "dataType": "refEnum",
28
+ "enums": {{{json enums}}},
29
+ {{/if}}
30
+ {{#if properties}}
31
+ "dataType": "refObject",
32
+ "properties": {
33
+ {{#each properties}}
34
+ "{{@key}}": {{{json this}}},
35
+ {{/each}}
36
+ },
37
+ "additionalProperties": {{{json additionalProperties}}},
38
+ {{/if}}
39
+ {{#if type}}
40
+ "dataType": "refAlias",
41
+ "type": {{{json type}}},
42
+ {{/if}}
43
+ },
44
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
45
+ {{/each}}
46
+ };
47
+ const templateService = new HapiTemplateService(
48
+ models,
49
+ {{{ json minimalSwaggerConfig }}},
50
+ { boomify, isBoom },
51
+ );
52
+
53
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
54
+
55
+ export function RegisterRoutes(server: any) {
56
+ // ###########################################################################################################
57
+ // NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
58
+ // Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa
59
+ // ###########################################################################################################
60
+ {{#each controllers}}
61
+ {{#each actions}}
62
+ const args{{../name}}_{{name}}: Record<string, TsoaRoute.ParameterSchema> = {
63
+ {{#each parameters}}
64
+ {{@key}}: {{{json this}}},
65
+ {{/each}}
66
+ };
67
+ server.route({
68
+ method: '{{method}}',
69
+ path: '{{fullPath}}',
70
+ options: {
71
+ pre: [
72
+ {{#if security.length}}
73
+ {
74
+ method: authenticateMiddleware({{json security}})
75
+ },
76
+ {{/if}}
77
+ {{#if uploadFile}}
78
+ {{#each uploadFileName}}
79
+ {
80
+ {{#if multiple}}
81
+ method: fileUploadMiddleware('{{name}}', true)
82
+ {{else}}
83
+ method: fileUploadMiddleware('{{name}}', false)
84
+ {{/if}}
85
+ },
86
+ {{/each}}
87
+ {{/if}}
88
+ ...(fetchMiddlewares<RouteOptionsPreAllOptions>({{../name}})),
89
+ ...(fetchMiddlewares<RouteOptionsPreAllOptions>({{../name}}.prototype.{{name}})),
90
+ ],
91
+ {{#if uploadFile}}
92
+ payload: {
93
+ output: 'stream',
94
+ parse: true,
95
+ multipart: true,
96
+ allow: 'multipart/form-data'
97
+ },
98
+ {{/if}}
99
+ handler: {{#if ../../iocModule}}async {{/if}}function {{../name}}_{{name}}(request: Request, h: ResponseToolkit) {
100
+
101
+ let validatedArgs: any[] = [];
102
+ try {
103
+ validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, request, h });
104
+ } catch (err) {
105
+ const error = err as any;
106
+ if (isBoom(error)) {
107
+ throw error;
108
+ }
109
+
110
+ const boomErr = boomify(error instanceof Error ? error : new Error(error.message), { statusCode: error.status || 500 });
111
+ boomErr.output.statusCode = error.status || 500;
112
+ boomErr.output.payload = {
113
+ name: error.name,
114
+ fields: error.fields,
115
+ message: error.message,
116
+ } as unknown as Payload;
117
+ throw boomErr;
118
+ }
119
+
120
+ {{#if ../../iocModule}}
121
+ const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer;
122
+
123
+ const controller: any = await container.get<{{../name}}>({{../name}});
124
+ if (typeof controller['setStatus'] === 'function') {
125
+ controller.setStatus(undefined);
126
+ }
127
+ {{else}}
128
+ const controller = new {{../name}}();
129
+ {{/if}}
130
+
131
+ return templateService.apiHandler({
132
+ methodName: '{{name}}',
133
+ controller,
134
+ h,
135
+ validatedArgs,
136
+ successStatus: {{successStatus}},
137
+ });
138
+ }
139
+ }
140
+ });
141
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
142
+ {{/each}}
143
+ {{/each}}
144
+
145
+ {{#if useSecurity}}
146
+
147
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
148
+
149
+ function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
150
+ return async function runAuthenticationMiddleware(request: any, h: any) {
151
+
152
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
153
+
154
+ // keep track of failed auth attempts so we can hand back the most
155
+ // recent one. This behavior was previously existing so preserving it
156
+ // here
157
+ const failedAttempts: any[] = [];
158
+ const pushAndRethrow = (error: any) => {
159
+ failedAttempts.push(error);
160
+ throw error;
161
+ };
162
+
163
+ const secMethodOrPromises: Promise<any>[] = [];
164
+ for (const secMethod of security) {
165
+ if (Object.keys(secMethod).length > 1) {
166
+ const secMethodAndPromises: Promise<any>[] = [];
167
+
168
+ for (const name in secMethod) {
169
+ secMethodAndPromises.push(
170
+ hapiAuthentication(request, name, secMethod[name])
171
+ .catch(pushAndRethrow)
172
+ );
173
+ }
174
+
175
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
176
+
177
+ secMethodOrPromises.push(Promise.all(secMethodAndPromises)
178
+ .then(users => { return users[0]; }));
179
+ } else {
180
+ for (const name in secMethod) {
181
+ secMethodOrPromises.push(
182
+ hapiAuthentication(request, name, secMethod[name])
183
+ .catch(pushAndRethrow)
184
+ );
185
+ }
186
+ }
187
+ }
188
+
189
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
190
+
191
+ try {
192
+ request['user'] = await Promise.any(secMethodOrPromises);
193
+ return request['user'];
194
+ }
195
+ catch(err) {
196
+ // Show most recent error as response
197
+ const error = failedAttempts.pop();
198
+ if (isBoom(error)) {
199
+ throw error;
200
+ }
201
+
202
+ const boomErr = boomify(error instanceof Error ? error : new Error(error.message), { statusCode: error.status || 500 });
203
+ boomErr.output.statusCode = error.status || 401;
204
+ boomErr.output.payload = {
205
+ name: error.name,
206
+ message: error.message,
207
+ } as unknown as Payload;
208
+
209
+ throw boomErr;
210
+ }
211
+
212
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
213
+ }
214
+ }
215
+ {{/if}}
216
+
217
+ {{#if useFileUploads}}
218
+ function fileUploadMiddleware(fieldname: string, multiple: boolean = false) {
219
+ return (request: Request, h: any) => {
220
+ if (!request.payload[fieldname]) {
221
+ return h.response(`${fieldname} is a required file(s).`).code(400);
222
+ }
223
+
224
+ const calculateFileInfo = (reqFile: any) => new Promise((resolve, reject) => {
225
+ const originalname = reqFile.hapi.filename;
226
+ const headers = reqFile.hapi.headers;
227
+ const contentTransferEncoding = headers['content-transfer-encoding'];
228
+ const encoding = contentTransferEncoding &&
229
+ contentTransferEncoding[0] &&
230
+ contentTransferEncoding[0].toLowerCase() || '7bit';
231
+ const mimetype = headers['content-type'] || 'text/plain';
232
+ const buffer = reqFile._data
233
+ return resolve({
234
+ fieldname,
235
+ originalname,
236
+ buffer,
237
+ encoding,
238
+ mimetype,
239
+ filename: originalname,
240
+ size: buffer.toString().length,
241
+ })
242
+ });
243
+
244
+ if (!multiple) {
245
+ return calculateFileInfo(request.payload[fieldname])
246
+ .then(fileMetadata => {
247
+ request.payload[fieldname] = fileMetadata;
248
+ return h.continue;
249
+ })
250
+ .catch(err => h.response(err.toString()).code(500));
251
+ } else {
252
+ const promises = request.payload[fieldname].map((reqFile: any) => calculateFileInfo(reqFile));
253
+ return Promise.all(promises)
254
+ .then(filesMetadata => {
255
+ request.payload[fieldname] = filesMetadata;
256
+ return h.continue;
257
+ })
258
+ .catch(err => h.response(err.toString()).code(500));
259
+ }
260
+ };
261
+ }
262
+ {{/if}}
263
+
264
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
265
+ }
266
+
267
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
@@ -0,0 +1,218 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
4
+ import type { TsoaRoute } from '@tsoa-next/runtime';
5
+ import { fetchMiddlewares, KoaTemplateService } from '@tsoa-next/runtime';
6
+ {{#each controllers}}
7
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
8
+ import { {{name}} } from '{{modulePath}}';
9
+ {{/each}}
10
+ {{#if authenticationModule}}
11
+ import { koaAuthentication } from '{{authenticationModule}}';
12
+ // @ts-ignore - no great way to install types from subpackage
13
+ {{/if}}
14
+ {{#if iocModule}}
15
+ import { iocContainer } from '{{iocModule}}';
16
+ import type { IocContainer, IocContainerFactory } from '@tsoa-next/runtime';
17
+ {{/if}}
18
+ import type { Context, Next, Middleware, Request as KRequest, Response as KResponse } from 'koa';
19
+ import type * as KoaRouter from '@koa/router';
20
+ {{#if useFileUploads}}
21
+ {{#if esm}}
22
+ import multer from '@koa/multer';
23
+ {{else}}
24
+ const multer = require('@koa/multer');
25
+ {{/if}}
26
+ {{/if}}
27
+ {{#if authenticationModule}}
28
+ const koaAuthenticationRecasted = koaAuthentication as (req: KRequest, securityName: string, scopes?: string[], res?: KResponse) => Promise<any>;
29
+ {{/if}}
30
+
31
+
32
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
33
+
34
+ const models: TsoaRoute.Models = {
35
+ {{#each models}}
36
+ "{{@key}}": {
37
+ {{#if enums}}
38
+ "dataType": "refEnum",
39
+ "enums": {{{json enums}}},
40
+ {{/if}}
41
+ {{#if properties}}
42
+ "dataType": "refObject",
43
+ "properties": {
44
+ {{#each properties}}
45
+ "{{@key}}": {{{json this}}},
46
+ {{/each}}
47
+ },
48
+ "additionalProperties": {{{json additionalProperties}}},
49
+ {{/if}}
50
+ {{#if type}}
51
+ "dataType": "refAlias",
52
+ "type": {{{json type}}},
53
+ {{/if}}
54
+ },
55
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
56
+ {{/each}}
57
+ };
58
+ const templateService = new KoaTemplateService(models, {{{ json minimalSwaggerConfig }}});
59
+
60
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
61
+
62
+
63
+ {{#if useFileUploads}}
64
+ export function RegisterRoutes(router: KoaRouter,opts?:{multer?:ReturnType<typeof multer>}) {
65
+ {{else}}
66
+ export function RegisterRoutes(router: KoaRouter) {
67
+ {{/if}}
68
+
69
+ // ###########################################################################################################
70
+ // NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
71
+ // Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa
72
+ // ###########################################################################################################
73
+
74
+ {{#if useFileUploads}}
75
+ const upload = opts?.multer || multer({{{json multerOpts}}});
76
+ {{/if}}
77
+
78
+ {{#each controllers}}
79
+ {{#each actions}}
80
+ const args{{../name}}_{{name}}: Record<string, TsoaRoute.ParameterSchema> = {
81
+ {{#each parameters}}
82
+ {{@key}}: {{{json this}}},
83
+ {{/each}}
84
+ };
85
+ router.{{method}}('{{fullPath}}',
86
+ {{#if security.length}}
87
+ authenticateMiddleware({{json security}}),
88
+ {{/if}}
89
+ {{#if uploadFile}}
90
+ upload.fields([
91
+ {{#each uploadFileName}}
92
+ {
93
+ name: {{json name}},
94
+ {{#if maxCount}}
95
+ maxCount: {{maxCount}}
96
+ {{/if}}
97
+ }{{#if @last}}{{else}},{{/if}}
98
+ {{/each}}
99
+ ]),
100
+ {{/if}}
101
+ ...(fetchMiddlewares<Middleware>({{../name}})),
102
+ ...(fetchMiddlewares<Middleware>({{../name}}.prototype.{{name}})),
103
+
104
+ async function {{../name}}_{{name}}(context: Context, next: Next) {
105
+
106
+ let validatedArgs: any[] = [];
107
+ try {
108
+ validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, context, next });
109
+ } catch (err) {
110
+ const error = err as any;
111
+ error.message ||= JSON.stringify({ fields: error.fields });
112
+ context.status = error.status;
113
+ context.throw(context.status, error.message, error);
114
+ }
115
+
116
+ {{#if ../../iocModule}}
117
+ const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(context.request) : iocContainer;
118
+
119
+ const controller: any = await container.get<{{../name}}>({{../name}});
120
+ if (typeof controller['setStatus'] === 'function') {
121
+ controller.setStatus(undefined);
122
+ }
123
+ {{else}}
124
+ const controller = new {{../name}}();
125
+ {{/if}}
126
+
127
+ return templateService.apiHandler({
128
+ methodName: '{{name}}',
129
+ controller,
130
+ context,
131
+ validatedArgs,
132
+ successStatus: {{successStatus}},
133
+ });
134
+ });
135
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
136
+ {{/each}}
137
+ {{/each}}
138
+
139
+ {{#if useSecurity}}
140
+
141
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
142
+
143
+ function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
144
+ return async function runAuthenticationMiddleware(context: any, next: any) {
145
+
146
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
147
+
148
+ // keep track of failed auth attempts so we can hand back the most
149
+ // recent one. This behavior was previously existing so preserving it
150
+ // here
151
+ const failedAttempts: any[] = [];
152
+ const pushAndRethrow = (error: any) => {
153
+ failedAttempts.push(error);
154
+ throw error;
155
+ };
156
+
157
+ const secMethodOrPromises: Promise<any>[] = [];
158
+ for (const secMethod of security) {
159
+ if (Object.keys(secMethod).length > 1) {
160
+ const secMethodAndPromises: Promise<any>[] = [];
161
+
162
+ for (const name in secMethod) {
163
+ secMethodAndPromises.push(
164
+ koaAuthenticationRecasted(context.request, name, secMethod[name], context.response)
165
+ .catch(pushAndRethrow)
166
+ );
167
+ }
168
+
169
+ secMethodOrPromises.push(Promise.all(secMethodAndPromises)
170
+ .then(users => { return users[0]; }));
171
+ } else {
172
+ for (const name in secMethod) {
173
+ secMethodOrPromises.push(
174
+ koaAuthenticationRecasted(context.request, name, secMethod[name], context.response)
175
+ .catch(pushAndRethrow)
176
+ );
177
+ }
178
+ }
179
+ }
180
+
181
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
182
+
183
+ let success;
184
+ try {
185
+ const user = await Promise.any(secMethodOrPromises);
186
+ success = true;
187
+ context.request['user'] = user;
188
+ }
189
+ catch(err) {
190
+ // Response was sent in middleware, abort
191
+ if(context.response.body) {
192
+ return;
193
+ }
194
+
195
+ // Show most recent error as response
196
+ const error = failedAttempts.pop();
197
+ context.status = error.status || 401;
198
+ context.throw(context.status, error.message, error);
199
+ }
200
+
201
+ // Response was sent in middleware, abort
202
+ if(context.response.body) {
203
+ return;
204
+ }
205
+
206
+ if (success) {
207
+ await next();
208
+ }
209
+
210
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
211
+ }
212
+ }
213
+ {{/if}}
214
+
215
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
216
+ }
217
+
218
+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
@@ -0,0 +1,33 @@
1
+ import { ExtendedSpecConfig } from '../cli';
2
+ import { Tsoa, Swagger } from '@tsoa-next/runtime';
3
+ export declare abstract class SpecGenerator {
4
+ protected readonly metadata: Tsoa.Metadata;
5
+ protected readonly config: ExtendedSpecConfig;
6
+ constructor(metadata: Tsoa.Metadata, config: ExtendedSpecConfig);
7
+ protected buildAdditionalProperties(type: Tsoa.Type): Swagger.BaseSchema<unknown>;
8
+ protected buildOperationIdTemplate(inlineTemplate: string): HandlebarsTemplateDelegate<any>;
9
+ protected getOperationId(controllerName: string, method: Tsoa.Method): string;
10
+ throwIfNotDataFormat(strToTest: string): Swagger.DataFormat;
11
+ throwIfNotDataType(strToTest: string): Swagger.DataType;
12
+ protected getSwaggerType(type: Tsoa.Type, title?: string): Swagger.BaseSchema;
13
+ protected abstract getSwaggerTypeForUnionType(type: Tsoa.UnionType, title?: string): Swagger.BaseSchema;
14
+ protected abstract getSwaggerTypeForIntersectionType(type: Tsoa.IntersectionType, title?: string): Swagger.BaseSchema;
15
+ protected abstract buildProperties(properties: Tsoa.Property[]): {
16
+ [propertyName: string]: Swagger.Schema2;
17
+ } | {
18
+ [propertyName: string]: Swagger.Schema3;
19
+ } | {
20
+ [propertyName: string]: Swagger.Schema31;
21
+ };
22
+ getSwaggerTypeForObjectLiteral(objectLiteral: Tsoa.NestedObjectLiteralType, title?: string): Swagger.BaseSchema;
23
+ protected getSwaggerTypeForReferenceType(_referenceType: Tsoa.ReferenceType): Swagger.BaseSchema;
24
+ protected getSwaggerTypeForVoid(_dataType: 'void' | 'undefined'): Swagger.BaseSchema;
25
+ protected determineImplicitAdditionalPropertiesValue: () => boolean;
26
+ protected getSwaggerTypeForPrimitiveType(dataType: Tsoa.PrimitiveTypeLiteral): Swagger.BaseSchema;
27
+ protected getSwaggerTypeForArrayType(arrayType: Tsoa.ArrayType, title?: string): Swagger.BaseSchema;
28
+ protected determineTypesUsedInEnum(anEnum: Array<string | number | boolean | null>): Set<"string" | "number" | "boolean">;
29
+ protected abstract getSwaggerTypeForEnumType(enumType: Tsoa.EnumType, title?: string): Swagger.Schema2 | Swagger.Schema3;
30
+ protected hasUndefined(property: Tsoa.Property): boolean;
31
+ protected queriesPropertyToQueryParameter(property: Tsoa.Property): Tsoa.Parameter;
32
+ protected isRequiredWithoutDefault(prop: Tsoa.Property | Tsoa.Parameter): boolean | undefined;
33
+ }