Skip to content

Commit b0f2be3

Browse files
authored
Log what port is listened on and for each http request (#109)
1 parent 2f82d41 commit b0f2be3

File tree

5 files changed

+158
-5
lines changed

5 files changed

+158
-5
lines changed

app/server.ts

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { verifyKey } from "discord-interactions";
33
import { createRequestHandler } from "@react-router/express";
44
import express from "express";
55
import bodyParser from "body-parser";
6+
import pinoHttp from "pino-http";
67

78
import { applicationKey } from "#~/helpers/env.server";
89

@@ -16,6 +17,10 @@ import * as track from "#~/commands/track";
1617
import setupTicket from "#~/commands/setupTickets";
1718

1819
export const app = express();
20+
21+
const logger = pinoHttp();
22+
app.use(logger);
23+
1924
app.use(
2025
createRequestHandler({
2126
// @ts-expect-error - virtual module provided by React Router at build time

index.dev.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ viteDevServer
2525
console.log({ error });
2626
});
2727

28-
app.listen(process.env.PORT || "3000", async () => {});
28+
const PORT = process.env.PORT || "3000";
29+
app.listen(PORT, async () => {
30+
console.log("INI", "Now listening on port", PORT);
31+
});

index.prod.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ const errorHandler = (error) => {
3737
process.on("uncaughtException", errorHandler);
3838
process.on("unhandledRejection", errorHandler);
3939

40-
app.listen(process.env.PORT || "3000", async () => {});
40+
const PORT = process.env.PORT || "3000";
41+
app.listen(PORT, async () => {
42+
console.log("INI", "Now listening on port", PORT);
43+
});

package-lock.json

+144-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"kysely-ctl": "^0.10.1",
5353
"lodash-es": "^4.17.21",
5454
"node-cron": "^3.0.0",
55+
"pino-http": "^10.4.0",
5556
"pretty-bytes": "^5.6.0",
5657
"reacord": "^0.6.0",
5758
"react": "^18.2.0",

0 commit comments

Comments
 (0)