diff --git a/src/app.ts b/src/app.ts index 21635e8..e7b19d2 100644 --- a/src/app.ts +++ b/src/app.ts @@ -6,6 +6,9 @@ import swaggerDocument from "./swagger.json"; import error from "./middlewares/error"; import { RegisterRoutes } from "./routes"; +const APP_HOST = process.env.APP_HOST || "0.0.0.0"; +const APP_PORT = +(process.env.APP_PORT || 3000); + (async () => { const app = express(); @@ -19,8 +22,5 @@ import { RegisterRoutes } from "./routes"; app.use(error); - const APP_HOST = process.env.APP_HOST || "0.0.0.0"; - const APP_PORT = +(process.env.APP_PORT || 3000); - app.listen(APP_PORT, APP_HOST, () => console.log(`Listening on: http://localhost:${APP_PORT}`)); })(); diff --git a/src/controllers/api-controller.ts b/src/controllers/api-controller.ts new file mode 100644 index 0000000..9381826 --- /dev/null +++ b/src/controllers/api-controller.ts @@ -0,0 +1,11 @@ +import { Controller, Get, Route, Tags } from "tsoa"; +import swaggerDocument from "../swagger.json"; + +@Route("api") +@Tags("OpenAPI") +export class APIController extends Controller { + @Get("openapi") + public getOpenAPI() { + return swaggerDocument; + } +}