Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team committed Oct 28, 2023
1 parent 3a271e5 commit 853aa0e
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 182 deletions.
5 changes: 0 additions & 5 deletions mocha.setup.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'mocha';
import { use } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { reset } from 'testdouble';

use(chaiAsPromised);

Expand All @@ -14,10 +13,6 @@ process.env = {

/** @type {import('mocha').RootHookObject} */
export const mochaHooks = {
/** @returns {void} */
afterEach() {
reset();
},
afterAll() {
process.env = { ...env };
},
Expand Down
154 changes: 41 additions & 113 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@myrotvorets/express-request-logger": "^1.2.0",
"@myrotvorets/facex": "^2.6.1",
"@myrotvorets/oav-installer": "^5.0.0",
"@myrotvorets/opentelemetry-configurator": "^7.0.0",
"@myrotvorets/otel-utils": "^0.0.10",
"@myrotvorets/opentelemetry-configurator": "^7.1.0",
"@myrotvorets/otel-utils": "^1.0.0",
"@opentelemetry/api": "^1.6.0",
"@opentelemetry/core": "^1.17.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
Expand All @@ -36,7 +36,7 @@
"express-openapi-validator": "^5.0.6"
},
"devDependencies": {
"@myrotvorets/eslint-config-myrotvorets-ts": "^2.22.5",
"@myrotvorets/eslint-config-myrotvorets-ts": "^2.22.6",
"@types/chai": "^4.3.9",
"@types/chai-as-promised": "^7.1.7",
"@types/express": "^4.17.20",
Expand All @@ -55,7 +55,6 @@
"mocha-reporter-sonarqube": "^2.0.4",
"nodemon": "^3.0.1",
"supertest": "^6.3.3",
"testdouble": "^3.20.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
Expand Down
2 changes: 0 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ sonar.sources=src
sonar.tests=test
sonar.testExecutionReportPaths=test-report.xml
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.eslint.reportPaths=eslint-report.json
sonar.sourceEncoding=UTF-8
sonar.coverage.exclusions=src/index.mts,src/lib/tracing.mts
4 changes: 4 additions & 0 deletions src/lib/container.mts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export function initializeContainer(): typeof container {
});

container.register('req', asValue(undefined));
process.on('beforeExit', () => {
container.dispose().catch((e) => console.error(e));
});

return container;
}

Expand Down
11 changes: 2 additions & 9 deletions src/server.mts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ export function createApp(): Express {
/* c8 ignore start */
export async function run(): Promise<void> {
const app = createApp();
const container = configureApp(app);
const env = container.resolve('environment');

const server = await createServer(app);
server.listen(env.PORT);

process.on('beforeExit', () => {
container.dispose().catch((e) => console.error(e));
});
configureApp(app);
await createServer(app);
}
/* c8 ignore end */
Loading

0 comments on commit 853aa0e

Please sign in to comment.