fix(portal-bff): use bracket notation for process.env access
The strict-TS option noPropertyAccessFromIndexSignature: true (set in
tsconfig.base.json per ADR-0004) forbids dot-notation access on index
signatures. process.env is typed as { [key: string]: string | undefined }
so process.env.PORT must be written process.env['PORT']. The Nx
generator wrote the dot form by default; fix to comply with the
project's strict-TS bar.
Touched: portal-bff main.ts and the three portal-bff-e2e support files
(global-setup, global-teardown, test-setup).
This commit is contained in:
@@ -7,8 +7,8 @@ module.exports = async function () {
|
||||
// Start services that that the app needs to run (e.g. database, docker-compose, etc.).
|
||||
console.log('\nSetting up...\n');
|
||||
|
||||
const host = process.env.HOST ?? 'localhost';
|
||||
const port = process.env.PORT ? Number(process.env.PORT) : 3000;
|
||||
const host = process.env['HOST'] ?? 'localhost';
|
||||
const port = process.env['PORT'] ? Number(process.env['PORT']) : 3000;
|
||||
await waitForPortOpen(port, { host });
|
||||
|
||||
// Hint: Use `globalThis` to pass variables to global teardown.
|
||||
|
||||
@@ -4,7 +4,7 @@ import { killPort } from '@nx/node/utils';
|
||||
module.exports = async function () {
|
||||
// Put clean up logic here (e.g. stopping services, docker-compose, etc.).
|
||||
// Hint: `globalThis` is shared between setup and teardown.
|
||||
const port = process.env.PORT ? Number(process.env.PORT) : 3000;
|
||||
const port = process.env['PORT'] ? Number(process.env['PORT']) : 3000;
|
||||
await killPort(port);
|
||||
console.log(globalThis.__TEARDOWN_MESSAGE__);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import axios from 'axios';
|
||||
|
||||
module.exports = async function () {
|
||||
// Configure axios for tests to use.
|
||||
const host = process.env.HOST ?? 'localhost';
|
||||
const port = process.env.PORT ?? '3000';
|
||||
const host = process.env['HOST'] ?? 'localhost';
|
||||
const port = process.env['PORT'] ?? '3000';
|
||||
axios.defaults.baseURL = `http://${host}:${port}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user