kozukata-toa/src/servers/titles/index.ts

32 lines
1.0 KiB
TypeScript

// THIS IMPORT **MUST** GO HERE. DO NOT MOVE IT. IT MUST OCCUR BEFORE ANYTHING HAPPENS WITH EXPRESS
// BUT AFTER EXPRESS IS IMPORTED.
/* eslint-disable import/order */
import express from "express";
import "express-async-errors";
import chunithmRouter from "./chunithm";
import CreateLogCtx from "lib/logger/logger";
import type { Express } from "express";
const logger = CreateLogCtx(__filename);
const app: Express = express();
// Pass the IP of the user up our increasingly insane chain of nginx/docker nonsense
app.set("trust proxy", ["loopback", "linklocal", "uniquelocal"]);
// we don't allow nesting in query strings.
app.set("query parser", "simple");
// taken from https://nodejs.org/api/process.html#process_event_unhandledrejection
// to avoid future deprecation.
process.on("unhandledRejection", (reason, promise) => {
// @ts-expect-error reason is an error, and the logger can handle errors
// it just refuses.
logger.error(reason, { promise });
});
app.use("/", chunithmRouter);
export default app;