feat: create basic express server with swagger documentation
This commit is contained in:
25
src/app.ts
Normal file
25
src/app.ts
Normal 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.'));
|
||||
|
||||
Reference in New Issue
Block a user