fix(backend): Verloren Swagger setup
This commit is contained in:
		
							parent
							
								
									5986ca57bf
								
							
						
					
					
						commit
						55ec9ca02e
					
				
					 3 changed files with 8 additions and 9 deletions
				
			
		|  | @ -7,6 +7,8 @@ import { responseTimeLogger } from './logging/responseTimeLogger.js'; | ||||||
| import responseTime from 'response-time'; | import responseTime from 'response-time'; | ||||||
| import { EnvVars, getNumericEnvVar } from './util/envvars.js'; | import { EnvVars, getNumericEnvVar } from './util/envvars.js'; | ||||||
| import apiRouter from './routes/router.js'; | import apiRouter from './routes/router.js'; | ||||||
|  | import swaggerMiddleware from './swagger'; | ||||||
|  | import swaggerUi from 'swagger-ui-express'; | ||||||
| 
 | 
 | ||||||
| const logger: Logger = getLogger(); | const logger: Logger = getLogger(); | ||||||
| 
 | 
 | ||||||
|  | @ -19,8 +21,11 @@ app.use(authenticateUser); | ||||||
| // Add response time logging
 | // Add response time logging
 | ||||||
| app.use(responseTime(responseTimeLogger)); | app.use(responseTime(responseTimeLogger)); | ||||||
| 
 | 
 | ||||||
|  | // Swagger
 | ||||||
| app.get('/api', apiRouter); | app.get('/api', apiRouter); | ||||||
| 
 | 
 | ||||||
|  | app.use('/api-docs', swaggerUi.serve, swaggerMiddleware); | ||||||
|  | 
 | ||||||
| async function startServer() { | async function startServer() { | ||||||
|     await initORM(); |     await initORM(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,10 +1,6 @@ | ||||||
| import express from 'express'; | import express from 'express'; | ||||||
| import { getFrontendAuthConfig } from '../controllers/auth.js'; | import { getFrontendAuthConfig } from '../controllers/auth.js'; | ||||||
| import { | import { authenticatedOnly, studentsOnly, teachersOnly } from '../middleware/auth/auth.js'; | ||||||
|     authenticatedOnly, |  | ||||||
|     studentsOnly, |  | ||||||
|     teachersOnly, |  | ||||||
| } from '../middleware/auth/auth.js'; |  | ||||||
| const router = express.Router(); | const router = express.Router(); | ||||||
| 
 | 
 | ||||||
| // Returns auth configuration for frontend
 | // Returns auth configuration for frontend
 | ||||||
|  |  | ||||||
|  | @ -26,8 +26,7 @@ const doc = { | ||||||
|                 type: 'oauth2', |                 type: 'oauth2', | ||||||
|                 flows: { |                 flows: { | ||||||
|                     implicit: { |                     implicit: { | ||||||
|                         authorizationUrl: |                         authorizationUrl: 'http://localhost:7080/realms/student/protocol/openid-connect/auth', | ||||||
|                             'http://localhost:7080/realms/student/protocol/openid-connect/auth', |  | ||||||
|                         scopes: { |                         scopes: { | ||||||
|                             openid: 'openid', |                             openid: 'openid', | ||||||
|                             profile: 'profile', |                             profile: 'profile', | ||||||
|  | @ -40,8 +39,7 @@ const doc = { | ||||||
|                 type: 'oauth2', |                 type: 'oauth2', | ||||||
|                 flows: { |                 flows: { | ||||||
|                     implicit: { |                     implicit: { | ||||||
|                         authorizationUrl: |                         authorizationUrl: 'http://localhost:7080/realms/teacher/protocol/openid-connect/auth', | ||||||
|                             'http://localhost:7080/realms/teacher/protocol/openid-connect/auth', |  | ||||||
|                         scopes: { |                         scopes: { | ||||||
|                             openid: 'openid', |                             openid: 'openid', | ||||||
|                             profile: 'profile', |                             profile: 'profile', | ||||||
|  |  | ||||||
		Reference in a new issue