Skip to content

Commit 39cfbeb

Browse files
authored
Merge pull request #323 from bcgov/chore/cleanup
General application updates
2 parents e44fccc + 4d444fa commit 39cfbeb

File tree

20 files changed

+386
-62
lines changed

20 files changed

+386
-62
lines changed

.github/environments/values.dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config:
1212
FRONTEND_OIDC_CLIENTID: nr-permit-connect-navigator-service-5188
1313
FRONTEND_OPENSTREETMAP_APIPATH: https://tile.openstreetmap.org
1414
FRONTEND_ORGBOOK_APIPATH: https://orgbook.gov.bc.ca/api/v4
15-
SERVER_APIPATH: /api/v1
15+
SERVER_APIPATH: /v1
1616
SERVER_ATS_APIPATH: https://i1api.nrs.gov.bc.ca/ats-api/v1
1717
SERVER_ATS_TOKENURL: https://i1api.nrs.gov.bc.ca/oauth2/v1/oauth/token?grant_type=client_credentials&disableDeveloperFilter=true&scope=ATS_API.*
1818
SERVER_BODYLIMIT: 30mb

.github/environments/values.prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config:
1212
FRONTEND_OIDC_CLIENTID: nr-permit-connect-navigator-service-5188
1313
FRONTEND_OPENSTREETMAP_APIPATH: https://tile.openstreetmap.org
1414
FRONTEND_ORGBOOK_APIPATH: https://orgbook.gov.bc.ca/api/v4
15-
SERVER_APIPATH: /api/v1
15+
SERVER_APIPATH: /v1
1616
SERVER_ATS_APIPATH: https://api.nrs.gov.bc.ca/ats-api/v1
1717
SERVER_ATS_TOKENURL: https://api.nrs.gov.bc.ca/oauth2/v1/oauth/token?grant_type=client_credentials&disableDeveloperFilter=true&scope=ATS_API.*
1818
SERVER_BODYLIMIT: 30mb

.github/environments/values.test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config:
1212
FRONTEND_OIDC_CLIENTID: nr-permit-connect-navigator-service-5188
1313
FRONTEND_OPENSTREETMAP_APIPATH: https://tile.openstreetmap.org
1414
FRONTEND_ORGBOOK_APIPATH: https://orgbook.gov.bc.ca/api/v4
15-
SERVER_APIPATH: /api/v1
15+
SERVER_APIPATH: /v1
1616
SERVER_ATS_APIPATH: https://t1api.nrs.gov.bc.ca/ats-api/v1
1717
SERVER_ATS_TOKENURL: https://t1api.nrs.gov.bc.ca/oauth2/v1/oauth/token?grant_type=client_credentials&disableDeveloperFilter=true&scope=ATS_API.*
1818
SERVER_BODYLIMIT: 30mb

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ USER 1001
6868
RUN npm ci --omit=dev && npm run prisma:generate
6969

7070
EXPOSE ${APP_PORT}
71-
CMD ["node", "./sbin/bin/www"]
71+
CMD ["node", "--max-old-space-size=50", "./sbin/server.js"]

app/app.ts

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { join } from 'path';
77
import querystring from 'querystring';
88
import { randomBytes } from 'crypto';
99

10-
import { name as appName, version as appVersion } from './package.json';
10+
import { version as appVersion } from './package.json';
1111
import { getLogger, httpLogger } from './src/components/log';
12-
import { DEFAULTCORS } from './src/utils/constants/application';
12+
import router from './src/routes';
1313
import { Problem } from './src/utils';
14+
import { DEFAULTCORS } from './src/utils/constants/application';
1415
import { readIdpList } from './src/utils/utils';
15-
import v1Router from './src/routes/v1';
1616
import { state } from './state';
1717

1818
import type { NextFunction, Request, Response } from 'express';
@@ -21,6 +21,7 @@ const log = getLogger(module.filename);
2121

2222
const appRouter = express.Router();
2323
const app = express();
24+
app.disable('x-powered-by');
2425
app.use(compression());
2526
app.use(cors(DEFAULTCORS));
2627
app.use(express.json({ limit: config.get('server.bodyLimit') }));
@@ -29,10 +30,6 @@ app.set('query parser', 'extended');
2930

3031
app.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
5553
if (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
9575
appRouter.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'

app/config/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"apiPath": "api/v1"
44
},
55
"server": {
6-
"apiPath": "/api/v1",
6+
"apiPath": "/v1",
77
"bodyLimit": "30mb",
88
"db": {
99
"database": "pcns",

0 commit comments

Comments
 (0)