Skip to content

Commit

Permalink
fix: service description, unnecessary server builder code,services ty…
Browse files Browse the repository at this point in the history
…pe defenition removed
  • Loading branch information
almog8k committed Jul 21, 2024
1 parent eae97ae commit 16ba7fb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "overseer",
"version": "1.0.0",
"description": "A geospatial data management worker service that handles initialization, merge, and finalization of geospatial layers.",
"description": "A geospatial data management worker service that handles initialization, merge, and finalization of geospatial jobs & tasks.",
"main": "./src/index.ts",
"scripts": {
"test:unit": "jest --config=./tests/configurations/unit/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const IGNORED_OUTGOING_TRACE_ROUTES = [/^.*\/v1\/metrics.*$/];
export const IGNORED_INCOMING_TRACE_ROUTES = [/^.*\/docs.*$/];

/* eslint-disable @typescript-eslint/naming-convention */
export const SERVICES: Record<string, symbol> = {
export const SERVICES = {
LOGGER: Symbol('Logger'),
CONFIG: Symbol('Config'),
TRACER: Symbol('Tracer'),
Expand Down
26 changes: 2 additions & 24 deletions src/serverBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import express from 'express';
import bodyParser from 'body-parser';
import compression from 'compression';
import { getErrorHandlerMiddleware } from '@map-colonies/error-express-handler';
import { inject, injectable } from 'tsyringe';
import { Logger } from '@map-colonies/js-logger';
import httpLogger from '@map-colonies/express-access-log-middleware';
import { collectMetricsExpressMiddleware, getTraceContexHeaderMiddleware } from '@map-colonies/telemetry';
import { collectMetricsExpressMiddleware } from '@map-colonies/telemetry';
import { SERVICES } from './common/constants';
import { IConfig } from './common/interfaces';

Expand All @@ -18,25 +14,7 @@ export class ServerBuilder {
}

public build(): express.Application {
this.registerPreRoutesMiddleware();
this.registerPostRoutesMiddleware();

return this.serverInstance;
}

private registerPreRoutesMiddleware(): void {
this.serverInstance.use(collectMetricsExpressMiddleware({}));
this.serverInstance.use(httpLogger({ logger: this.logger, ignorePaths: ['/metrics'] }));

if (this.config.get<boolean>('server.response.compression.enabled')) {
this.serverInstance.use(compression(this.config.get<compression.CompressionFilter>('server.response.compression.options')));
}

this.serverInstance.use(bodyParser.json(this.config.get<bodyParser.Options>('server.request.payload')));
this.serverInstance.use(getTraceContexHeaderMiddleware());
}

private registerPostRoutesMiddleware(): void {
this.serverInstance.use(getErrorHandlerMiddleware());
return this.serverInstance;
}
}

0 comments on commit 16ba7fb

Please sign in to comment.