diff --git a/backend/src/app.ts b/backend/src/app.ts index 1f518a4a..a69d3f10 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -7,6 +7,8 @@ import { responseTimeLogger } from './logging/responseTimeLogger.js'; import responseTime from 'response-time'; import { EnvVars, getNumericEnvVar } from './util/envvars.js'; import apiRouter from './routes/router.js'; +import swaggerMiddleware from './swagger'; +import swaggerUi from 'swagger-ui-express'; const logger: Logger = getLogger(); @@ -19,8 +21,11 @@ app.use(authenticateUser); // Add response time logging app.use(responseTime(responseTimeLogger)); +// Swagger app.get('/api', apiRouter); +app.use('/api-docs', swaggerUi.serve, swaggerMiddleware); + async function startServer() { await initORM(); diff --git a/backend/src/routes/auth.ts b/backend/src/routes/auth.ts index 35c805e9..778e51fd 100644 --- a/backend/src/routes/auth.ts +++ b/backend/src/routes/auth.ts @@ -1,10 +1,6 @@ import express from 'express'; import { getFrontendAuthConfig } from '../controllers/auth.js'; -import { - authenticatedOnly, - studentsOnly, - teachersOnly, -} from '../middleware/auth/auth.js'; +import { authenticatedOnly, studentsOnly, teachersOnly } from '../middleware/auth/auth.js'; const router = express.Router(); // Returns auth configuration for frontend diff --git a/docs/api/generate.ts b/docs/api/generate.ts index 32f3922d..87814c19 100644 --- a/docs/api/generate.ts +++ b/docs/api/generate.ts @@ -26,8 +26,7 @@ const doc = { type: 'oauth2', flows: { implicit: { - authorizationUrl: - 'http://localhost:7080/realms/student/protocol/openid-connect/auth', + authorizationUrl: 'http://localhost:7080/realms/student/protocol/openid-connect/auth', scopes: { openid: 'openid', profile: 'profile', @@ -40,8 +39,7 @@ const doc = { type: 'oauth2', flows: { implicit: { - authorizationUrl: - 'http://localhost:7080/realms/teacher/protocol/openid-connect/auth', + authorizationUrl: 'http://localhost:7080/realms/teacher/protocol/openid-connect/auth', scopes: { openid: 'openid', profile: 'profile',