tsoa setup
This commit is contained in:
@@ -0,0 +1 @@
|
||||
generated/
|
||||
@@ -14,6 +14,7 @@
|
||||
"typescript": "~5.9.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tsoa/runtime": "^6.6.0",
|
||||
"express": "^5.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Controller, Get, Route, SuccessResponse } from 'tsoa';
|
||||
|
||||
export interface User {
|
||||
email: string;
|
||||
name: string;
|
||||
phoneNumbers: string[];
|
||||
}
|
||||
|
||||
export type UserCreationParams = Pick<User, "email" | "name" | "phoneNumbers">;
|
||||
|
||||
@Route('health')
|
||||
export class HealthCheckController extends Controller {
|
||||
@Get('ok')
|
||||
@SuccessResponse('200', 'OK')
|
||||
public async getOk(
|
||||
): Promise<string> {
|
||||
this.setStatus(200);
|
||||
return 'Ok';
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
import express from 'express';
|
||||
import { RegisterRoutes } from './generated/routes.js';
|
||||
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
app.get('/', (_, res) => {
|
||||
res.send('Hello World!');
|
||||
});
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
app.use(express.json());
|
||||
|
||||
RegisterRoutes(app);
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is running at http://localhost:${port}`);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as express from 'express';
|
||||
|
||||
export async function expressAuthentication(
|
||||
request: express.Request,
|
||||
securityName: string,
|
||||
scopes?: string[]
|
||||
): Promise<any> {
|
||||
console.dir({ request, securityName, scopes });
|
||||
return {};
|
||||
}
|
||||
@@ -40,6 +40,21 @@
|
||||
"noUncheckedSideEffectImports": true,
|
||||
"moduleDetection": "force",
|
||||
"skipLibCheck": true,
|
||||
|
||||
// Custom Options
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"useDefineForClassFields": false,
|
||||
"moduleResolution": "nodenext",
|
||||
"incremental": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictBindCallApply": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
},
|
||||
"files": ["./src/index.ts"],
|
||||
"files": ["./src/index.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user