Skip to content

Commit

Permalink
Merge pull request #327 from gas-buddy/dhruv/add-logs
Browse files Browse the repository at this point in the history
Add additional logs to help with troubleshooting
  • Loading branch information
dhruv-m-patel committed Jan 24, 2024
2 parents 7a8791a + 4e27350 commit 1b2a569
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gasbuddy/service",
"version": "12.20.1",
"version": "12.20.2",
"description": "An opinionated framework for building configuration driven services - web, api, or job. Uses swagger, pino logging, express, confit, Typescript and Jest.",
"main": "build/index.js",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions src/express-app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export async function startApp<
};
const options = serviceImpl.configure?.(startOptions, baseOptions) || baseOptions;

logger.info('Loading configuration');
const config = await loadConfiguration({
name,
configurationDirectories: options.configurationDirectories,
Expand Down Expand Up @@ -156,6 +157,7 @@ export async function startApp<
}

if (config.get('trustProxy')) {
logger.info('Setting up Trust Proxy');
app.set('trust proxy', config.get('trustProxy'));
}

Expand All @@ -180,13 +182,16 @@ export async function startApp<
next();
}
};
logger.info('Setting up requests to attach service locals');
app.use(attachServiceLocals);

if (routing?.cookieParser) {
logger.info('Enabling cookie parser');
app.use(cookieParser());
}

if (routing?.bodyParsers?.json) {
logger.info('Enabling body parser for json requests');
app.use(
express.json({
verify(req, res, buf) {
Expand All @@ -199,6 +204,7 @@ export async function startApp<
);
}
if (routing?.bodyParsers?.form) {
logger.info('Enabling body parser for form submissions');
app.use(express.urlencoded());
}

Expand Down Expand Up @@ -226,10 +232,12 @@ export async function startApp<
next();
}
};
logger.info('Setting up authorization middleware');
app.use(authorize);
}

if (routing?.static?.enabled) {
logger.info('Enabling static assets');
const localdir = path.resolve(rootDirectory, routing?.static?.path || 'public');
if (routing.static.mountPath) {
app.use(routing.static.mountPath, express.static(localdir));
Expand Down Expand Up @@ -266,6 +274,7 @@ export async function startApp<
);
}
if (routing?.openapi) {
logger.info('Setting up OpenAPI integration');
app.use(openApi(app, rootDirectory, codepath, options.openApiOptions));
}

Expand Down

0 comments on commit 1b2a569

Please sign in to comment.