Swagger API documentation

This commit is contained in:
2024-12-09 19:06:50 +01:00
parent 9df62d037d
commit 4215bbf9c2
18 changed files with 1383 additions and 121 deletions

View File

@@ -1,6 +1,8 @@
import express from 'express'
import cors from 'cors'
import bodyParser from 'body-parser'
import swaggerJsdoc from "swagger-jsdoc"
import swaggerUi from "swagger-ui-express"
import { api } from './routes/api.routes'
import { startDatabase } from './database'
import { order } from './routes/order.routes'
@@ -12,6 +14,7 @@ import { location } from './routes/location.routes'
import { city } from './routes/city.routes'
import { exercises } from './routes/exercise.routes'
import { files } from './routes/files.routes'
import swaggerFile from './swagger.json'
const app = express()
const port = 3000
@@ -46,6 +49,17 @@ app.use("/accounts", account)
app.use("/cities", city)
app.use("/concerts", concert)
// Swagger API documentation
const specs = swaggerJsdoc(swaggerFile);
app.use(
"/api-docs",
swaggerUi.serve,
swaggerUi.setup(specs, { explorer: true })
)
// Start server
const server = app.listen(port, () => {
console.log(`Server is running and listening to port ${port}`)