Skip to content

Commit

Permalink
Start working on private-rest.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Duvivier committed Oct 30, 2024
1 parent 88eb347 commit 04e86c0
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 17 deletions.
33 changes: 33 additions & 0 deletions public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,39 @@
}
]
}
},
"/api/v3/apps/{slug}/version": {
"post": {
"operationId": "CreateVersion",
"responses": {
"200": {
"description": "Ok",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/Device"
},
"type": "array"
}
}
}
}
},
"description": "Get list of devices (badges)",
"tags": ["public"],
"security": [],
"parameters": [
{
"in": "path",
"name": "slug",
"required": true,
"schema": {
"type": "string"
}
}
]
}
}
},
"servers": [
Expand Down
14 changes: 14 additions & 0 deletions src/controllers/private-rest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Path, Post, Route, Tags } from "tsoa";
import { Device } from "../db/models";

@Route("/api/v3")
@Tags("public")
export class PrivateRestController {
/**
* Get list of devices (badges)
*/
@Post("/apps/{slug}/version")
public async createVersion(@Path() slug: string): Promise<Device[]> {
throw new Error("Not implemented");
}
}
84 changes: 67 additions & 17 deletions src/generated/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
ExpressTemplateService,
} from "@tsoa/runtime";
// 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
import { RestController } from "./../public-rest.js";
import { PublicRestController } from "./../controllers/public-rest.js";
// 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
import { PrivateRestController } from "./../controllers/private-rest.js";
import type {
Request as ExRequest,
Response as ExResponse,
Expand Down Expand Up @@ -79,10 +81,12 @@ export function RegisterRoutes(app: Router) {
// ###########################################################################################################
app.get(
"/api/v3/devices",
...fetchMiddlewares<RequestHandler>(RestController),
...fetchMiddlewares<RequestHandler>(RestController.prototype.getDevices),
...fetchMiddlewares<RequestHandler>(PublicRestController),
...fetchMiddlewares<RequestHandler>(
PublicRestController.prototype.getDevices
),

async function RestController_getDevices(
async function PublicRestController_getDevices(
request: ExRequest,
response: ExResponse,
next: any
Expand All @@ -99,7 +103,7 @@ export function RegisterRoutes(app: Router) {
response,
});

const controller = new RestController();
const controller = new PublicRestController();

await templateService.apiHandler({
methodName: "getDevices",
Expand All @@ -117,10 +121,12 @@ export function RegisterRoutes(app: Router) {
// 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
app.get(
"/api/v3/categories",
...fetchMiddlewares<RequestHandler>(RestController),
...fetchMiddlewares<RequestHandler>(RestController.prototype.getCategories),
...fetchMiddlewares<RequestHandler>(PublicRestController),
...fetchMiddlewares<RequestHandler>(
PublicRestController.prototype.getCategories
),

async function RestController_getCategories(
async function PublicRestController_getCategories(
request: ExRequest,
response: ExResponse,
next: any
Expand All @@ -137,7 +143,7 @@ export function RegisterRoutes(app: Router) {
response,
});

const controller = new RestController();
const controller = new PublicRestController();

await templateService.apiHandler({
methodName: "getCategories",
Expand All @@ -155,10 +161,10 @@ export function RegisterRoutes(app: Router) {
// 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
app.get(
"/api/v3/apps",
...fetchMiddlewares<RequestHandler>(RestController),
...fetchMiddlewares<RequestHandler>(RestController.prototype.getApps),
...fetchMiddlewares<RequestHandler>(PublicRestController),
...fetchMiddlewares<RequestHandler>(PublicRestController.prototype.getApps),

async function RestController_getApps(
async function PublicRestController_getApps(
request: ExRequest,
response: ExResponse,
next: any
Expand All @@ -180,7 +186,7 @@ export function RegisterRoutes(app: Router) {
response,
});

const controller = new RestController();
const controller = new PublicRestController();

await templateService.apiHandler({
methodName: "getApps",
Expand All @@ -198,10 +204,12 @@ export function RegisterRoutes(app: Router) {
// 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
app.get(
"/api/v3/apps/:slug",
...fetchMiddlewares<RequestHandler>(RestController),
...fetchMiddlewares<RequestHandler>(RestController.prototype.getAppDetails),
...fetchMiddlewares<RequestHandler>(PublicRestController),
...fetchMiddlewares<RequestHandler>(
PublicRestController.prototype.getAppDetails
),

async function RestController_getAppDetails(
async function PublicRestController_getAppDetails(
request: ExRequest,
response: ExResponse,
next: any
Expand All @@ -227,7 +235,7 @@ export function RegisterRoutes(app: Router) {
response,
});

const controller = new RestController();
const controller = new PublicRestController();

await templateService.apiHandler({
methodName: "getAppDetails",
Expand All @@ -243,6 +251,48 @@ export function RegisterRoutes(app: Router) {
}
);
// 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
app.post(
"/api/v3/apps/:slug/version",
...fetchMiddlewares<RequestHandler>(PrivateRestController),
...fetchMiddlewares<RequestHandler>(
PrivateRestController.prototype.createVersion
),

async function PrivateRestController_createVersion(
request: ExRequest,
response: ExResponse,
next: any
) {
const args: Record<string, TsoaRoute.ParameterSchema> = {
slug: { in: "path", name: "slug", required: true, dataType: "string" },
};

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

let validatedArgs: any[] = [];
try {
validatedArgs = templateService.getValidatedArgs({
args,
request,
response,
});

const controller = new PrivateRestController();

await templateService.apiHandler({
methodName: "createVersion",
controller,
response,
next,
validatedArgs,
successStatus: undefined,
});
} catch (err) {
return next(err);
}
}
);
// 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

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

Expand Down

0 comments on commit 04e86c0

Please sign in to comment.