QnA/api/src/main.ts
2023-08-29 19:10:54 -06:00

35 lines
No EOL
779 B
TypeScript

// Filepath aliasing to avoid relative-imports whenever possible, this must stay
// at the top of this file as the first statement
import "module-alias/register";
import { Logger } from "tslog";
import { start } from "~/hapi";
export const isDev = process.env.NODE_ENV?.startsWith(`dev`);
let logLevel = 4;
if (process.env.LOG_LEVEL) {
logLevel = parseInt(process.env.LOG_LEVEL);
} else if (isDev) {
logLevel = 0;
};
export const log = new Logger({
minLevel: logLevel,
hideLogPositionForProduction: !isDev,
maskValuesOfKeys: [ `password`, `token` ],
});
async function main() {
let server = await start();
log.info(`Server listening`)
};
if (require.main === module) {
process.on(`unhandledRejection`, err => {
log.error(err);
process.exit(1);
});
main();
};