feat: create basic express server with swagger documentation

This commit is contained in:
2025-12-01 02:24:52 +01:00
parent 56975a0e92
commit 1e60fc23ab
4 changed files with 54 additions and 53 deletions

25
src/app.ts Normal file
View File

@@ -0,0 +1,25 @@
import * as express from 'express';
import router from './routes';
const app = express();
const swaggerJsdocOpts = {
failOnErrors: true,
definition: {
openapi: '3.0.0',
info: {
title: 'kittyurl',
version: '0.0.1'
}
},
apis: ['./src/routes/*.ts']
};
const swaggerUi = require('swagger-ui-express');
const swaggerJsdoc = require('swagger-jsdoc');
const swaggerSpec = swaggerJsdoc(swaggerJsdocOpts);
app.use(express.json());
app.use(router);
app.use('/swagger', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.listen(6567, () => console.log('(HTTP Server) Listening on port 6567.'));