API-35: First steps in swagger integration

This commit is contained in:
Patrick Müller 2022-01-08 15:06:39 +01:00
parent 5257797866
commit ec533394ce
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE
6 changed files with 3605 additions and 55 deletions

6
.gitignore vendored
View File

@ -2,3 +2,9 @@
.idea .idea
**/*.iml **/*.iml
.env .env
# Build output
dist/
logs/
node_modules/
public/

12
app.ts
View File

@ -1,6 +1,7 @@
import express from 'express'; import express from 'express';
import * as http from 'http'; import * as http from 'http';
import * as dotenv from 'dotenv'; import * as dotenv from 'dotenv';
import swaggerUi from 'swagger-ui-express';
// Router imports // Router imports
import {partyPlanerRouter} from './src/models/partyplaner/PartyPlaner.router'; import {partyPlanerRouter} from './src/models/partyplaner/PartyPlaner.router';
import {highlightMarkerRouter} from './src/models/twitch-highlight-marker/HighlightMarker.router'; import {highlightMarkerRouter} from './src/models/twitch-highlight-marker/HighlightMarker.router';
@ -30,6 +31,17 @@ app.use(express.json());
// Use CORS // Use CORS
app.use(cors()); app.use(cors());
// Swagger documentation
app.use(
'/docs',
swaggerUi.serve,
swaggerUi.setup(undefined, {
swaggerOptions: {
url: '/public/swagger.json'
}
})
);
// Add routers // Add routers
app.use('/dhbw-service', dhbwServiceRouter); app.use('/dhbw-service', dhbwServiceRouter);
app.use('/twitch-highlight-marker', highlightMarkerRouter); app.use('/twitch-highlight-marker', highlightMarkerRouter);

3558
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,40 @@
{ {
"name": "PlutoDevExpressAPI", "name": "plutodev_express_api",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "tsc && node ./dist/app.js", "start": "tsc && node ./dist/app.js",
"build": "tsc", "build": "tsc",
"debug": "export DEBUG=* && npm run start", "debug": "export DEBUG=* && npm run start",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1",
}, "swagger": "tsoa spec"
"keywords": [], },
"author": "", "keywords": [],
"license": "ISC", "author": "",
"dependencies": { "license": "ISC",
"app-root-path": "^3.0.0", "dependencies": {
"bcrypt": "^5.0.1", "app-root-path": "^3.0.0",
"cors": "^2.8.5", "bcrypt": "^5.0.1",
"debug": "^4.3.1", "cors": "^2.8.5",
"dotenv": "^8.2.0", "debug": "^4.3.1",
"express": "^4.17.1", "dotenv": "^8.2.0",
"guid-typescript": "^1.0.9", "express": "^4.17.1",
"mariadb": "^2.5.3", "guid-typescript": "^1.0.9",
"winston": "^3.3.3" "mariadb": "^2.5.3",
}, "swagger-ui-express": "^4.3.0",
"devDependencies": { "tsoa": "^3.14.1",
"@types/app-root-path": "^1.2.4", "winston": "^3.3.3"
"@types/bcrypt": "^3.0.1", },
"@types/debug": "^4.1.5", "devDependencies": {
"@types/express": "^4.17.11", "@types/app-root-path": "^1.2.4",
"@types/winston": "^2.4.4", "@types/bcrypt": "^3.0.1",
"source-map-support": "^0.5.19", "@types/debug": "^4.1.5",
"tslint": "^6.1.3", "@types/express": "^4.17.11",
"typescript": "^4.1.5" "@types/swagger-ui-express": "^4.1.3",
} "@types/winston": "^2.4.4",
"source-map-support": "^0.5.19",
"tslint": "^6.1.3",
"typescript": "^4.1.5"
}
} }

View File

@ -5,6 +5,8 @@
"outDir": "./dist", "outDir": "./dist",
"strict": true, "strict": true,
"esModuleInterop": true, "esModuleInterop": true,
"inlineSourceMap": true "inlineSourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
} }
} }

View File

@ -0,0 +1,8 @@
{
"entryFile": "app.ts",
"noImplicitAdditionalProperties": "throw-on-extras",
"spec": {
"outputDirectory": "public",
"specVersion": 3
}
}