Skip to content

Commit 03d4152

Browse files
committed
chore: add autogenerated routes from tsoa
1 parent e2ca89b commit 03d4152

3 files changed

Lines changed: 145 additions & 53 deletions

File tree

tsoa-routes/routes.ts

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@
33
import type { TsoaRoute } from "@tsoa/runtime";
44
import { fetchMiddlewares, ExpressTemplateService } from "@tsoa/runtime";
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
6-
import { UsersController } from "./../src/controllers/usersController";
6+
import { UsersController } from "./../src/controllers/usersController.js";
77
// 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 { LanguagesController } from "./../src/controllers/languagesController";
8+
import { LanguagesController } from "./../src/controllers/languagesController.js";
99
// 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
10-
import { BooksController } from "./../src/controllers/booksController";
10+
import { BooksController } from "./../src/controllers/booksController.js";
1111
// 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
12-
import { AuthorsController } from "./../src/controllers/authorsController";
12+
import { AuthorsController } from "./../src/controllers/authorsController.js";
1313
import type { Request as ExRequest, Response as ExResponse, RequestHandler, Router } from "express";
14+
import multer from "multer";
1415

1516
// 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
1617

1718
const models: TsoaRoute.Models = {
18-
UserRequest: {
19+
UserCreateRequest: {
1920
dataType: "refObject",
2021
properties: {
21-
userId: { dataType: "double", required: true },
2222
username: { dataType: "string", required: true },
2323
},
2424
additionalProperties: false,
2525
},
2626
// 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
27-
UserCreateRequest: {
27+
UserResponse: {
2828
dataType: "refObject",
2929
properties: {
30+
userId: { dataType: "double", required: true },
3031
username: { dataType: "string", required: true },
3132
},
3233
additionalProperties: false,
@@ -48,7 +49,7 @@ const models: TsoaRoute.Models = {
4849
additionalProperties: false,
4950
},
5051
// 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
51-
LanguageRequest: {
52+
LanguageResponse: {
5253
dataType: "refObject",
5354
properties: {
5455
languageCode: { dataType: "string", required: true },
@@ -87,16 +88,16 @@ const models: TsoaRoute.Models = {
8788
additionalProperties: false,
8889
},
8990
// 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
90-
BookAuthor: {
91+
BookAuthorResponse: {
9192
dataType: "refObject",
9293
properties: {
93-
AuthorId: { dataType: "double", required: true },
94-
BookId: { dataType: "double", required: true },
94+
authorId: { dataType: "double", required: true },
95+
bookId: { dataType: "double", required: true },
9596
},
9697
additionalProperties: false,
9798
},
9899
// 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
99-
BookRequest: {
100+
BookResponse: {
100101
dataType: "refObject",
101102
properties: {
102103
bookId: { dataType: "double", required: true },
@@ -139,13 +140,13 @@ const models: TsoaRoute.Models = {
139140
additionalProperties: false,
140141
},
141142
// 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-
AuthorRequest: {
143+
AuthorResponse: {
143144
dataType: "refObject",
144145
properties: {
145-
AuthorId: { dataType: "double", required: true },
146-
Middlename: { dataType: "string" },
147-
Name: { dataType: "string", required: true },
148-
Surname: { dataType: "string" },
146+
authorId: { dataType: "double", required: true },
147+
middlename: { dataType: "string" },
148+
name: { dataType: "string", required: true },
149+
surname: { dataType: "string" },
149150
},
150151
additionalProperties: false,
151152
},
@@ -165,12 +166,14 @@ const templateService = new ExpressTemplateService(models, { noImplicitAdditiona
165166

166167
// 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
167168

168-
export function RegisterRoutes(app: Router) {
169+
export function RegisterRoutes(app: Router, opts?: { multer?: ReturnType<typeof multer> }) {
169170
// ###########################################################################################################
170171
// 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
171172
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa
172173
// ###########################################################################################################
173174

175+
const upload = opts?.multer || multer({ limits: { fileSize: 8388608 } });
176+
174177
const argsUsersController_createUser: Record<string, TsoaRoute.ParameterSchema> = {
175178
body: { in: "body", name: "body", required: true, ref: "UserCreateRequest" },
176179
};
@@ -511,6 +514,44 @@ export function RegisterRoutes(app: Router) {
511514
}
512515
);
513516
// 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
517+
const argsBooksController_addImageToBook: Record<string, TsoaRoute.ParameterSchema> = {
518+
bookId: { in: "path", name: "bookId", required: true, dataType: "double" },
519+
file: { in: "formData", name: "file", required: true, dataType: "file" },
520+
};
521+
app.post(
522+
"/api/books/:bookId/upload",
523+
upload.fields([
524+
{
525+
name: "file",
526+
maxCount: 1,
527+
},
528+
]),
529+
...fetchMiddlewares<RequestHandler>(BooksController),
530+
...fetchMiddlewares<RequestHandler>(BooksController.prototype.addImageToBook),
531+
532+
async function BooksController_addImageToBook(request: ExRequest, response: ExResponse, next: any) {
533+
// 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
534+
535+
let validatedArgs: any[] = [];
536+
try {
537+
validatedArgs = templateService.getValidatedArgs({ args: argsBooksController_addImageToBook, request, response });
538+
539+
const controller = new BooksController();
540+
541+
await templateService.apiHandler({
542+
methodName: "addImageToBook",
543+
controller,
544+
response,
545+
next,
546+
validatedArgs,
547+
successStatus: 201,
548+
});
549+
} catch (err) {
550+
return next(err);
551+
}
552+
}
553+
);
554+
// 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
514555
const argsBooksController_createBook: Record<string, TsoaRoute.ParameterSchema> = {
515556
body: { in: "body", name: "body", required: true, ref: "BookCreateRequest" },
516557
};

0 commit comments

Comments
 (0)