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,5 +1,5 @@
{ {
"name": "PlutoDevExpressAPI", "name": "plutodev_express_api",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
@ -7,7 +7,8 @@
"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": [], "keywords": [],
"author": "", "author": "",
@ -21,6 +22,8 @@
"express": "^4.17.1", "express": "^4.17.1",
"guid-typescript": "^1.0.9", "guid-typescript": "^1.0.9",
"mariadb": "^2.5.3", "mariadb": "^2.5.3",
"swagger-ui-express": "^4.3.0",
"tsoa": "^3.14.1",
"winston": "^3.3.3" "winston": "^3.3.3"
}, },
"devDependencies": { "devDependencies": {
@ -28,6 +31,7 @@
"@types/bcrypt": "^3.0.1", "@types/bcrypt": "^3.0.1",
"@types/debug": "^4.1.5", "@types/debug": "^4.1.5",
"@types/express": "^4.17.11", "@types/express": "^4.17.11",
"@types/swagger-ui-express": "^4.1.3",
"@types/winston": "^2.4.4", "@types/winston": "^2.4.4",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",
"tslint": "^6.1.3", "tslint": "^6.1.3",

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
}
}