@@ -7,12 +7,12 @@ import { join } from 'path';
77import querystring from 'querystring' ;
88import { randomBytes } from 'crypto' ;
99
10- import { name as appName , version as appVersion } from './package.json' ;
10+ import { version as appVersion } from './package.json' ;
1111import { getLogger , httpLogger } from './src/components/log' ;
12- import { DEFAULTCORS } from './src/utils/constants/application ' ;
12+ import router from './src/routes ' ;
1313import { Problem } from './src/utils' ;
14+ import { DEFAULTCORS } from './src/utils/constants/application' ;
1415import { readIdpList } from './src/utils/utils' ;
15- import v1Router from './src/routes/v1' ;
1616import { state } from './state' ;
1717
1818import type { NextFunction , Request , Response } from 'express' ;
@@ -21,6 +21,7 @@ const log = getLogger(module.filename);
2121
2222const appRouter = express . Router ( ) ;
2323const app = express ( ) ;
24+ app . disable ( 'x-powered-by' ) ;
2425app . use ( compression ( ) ) ;
2526app . use ( cors ( DEFAULTCORS ) ) ;
2627app . use ( express . json ( { limit : config . get ( 'server.bodyLimit' ) } ) ) ;
@@ -29,10 +30,6 @@ app.set('query parser', 'extended');
2930
3031app . use ( ( _req , res , next ) => {
3132 res . locals . cspNonce = randomBytes ( 32 ) . toString ( 'hex' ) ;
32- next ( ) ;
33- } ) ;
34-
35- app . use (
3633 helmet ( {
3734 contentSecurityPolicy : {
3835 directives : {
@@ -48,8 +45,9 @@ app.use(
4845 'script-src' : [ "'self'" , ( _req , res : any ) => `'nonce-${ res . locals . cspNonce } '` ] // eslint-disable-line
4946 }
5047 }
51- } )
52- ) ;
48+ } ) ;
49+ next ( ) ;
50+ } ) ;
5351
5452// Skip if running tests
5553if ( process . env . NODE_ENV !== 'test' ) {
@@ -73,24 +71,6 @@ app.get('/robots.txt', (_req: Request, res: Response): void => {
7371 res . send ( 'User-agent: *\nDisallow: /' ) ;
7472} ) ;
7573
76- // Base API Directory
77- appRouter . get ( '/api' , ( _req : Request , res : Response ) : void => {
78- if ( state . shutdown ) {
79- throw new Error ( 'Server shutting down' ) ;
80- } else {
81- res . status ( 200 ) . json ( {
82- app : {
83- gitRev : state . gitRev ,
84- name : appName ,
85- nodeVersion : process . version ,
86- version : appVersion
87- } ,
88- endpoints : [ '/api/v1' ] ,
89- versions : [ 1 ]
90- } ) ;
91- }
92- } ) ;
93-
9474// Frontend configuration endpoint
9575appRouter . get ( '/config' , ( _req : Request , res : Response , next : NextFunction ) : void => {
9676 try {
@@ -106,8 +86,8 @@ appRouter.get('/config', (_req: Request, res: Response, next: NextFunction): voi
10686 }
10787} ) ;
10888
109- // v1 Router
110- appRouter . use ( config . get ( 'server.apiPath' ) , v1Router ) ;
89+ // Base API Directory
90+ appRouter . use ( '/api' , router ) ;
11191
11292// Host the static frontend assets
11393// This route assumes being executed from '/sbin'
0 commit comments