mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-05 13:28:08 +03:00
fix: don't shadow the healthcheck endpoint... (#1709)
This commit is contained in:
@@ -5,7 +5,7 @@ import { Client, type CommandInteraction, Intents, type SelectMenuInteraction }
|
||||
import { Env, ServerConfig } from "./config";
|
||||
import { handleIsCommand } from "./interaction-handlers/handle-is-command";
|
||||
import { GetUserAndTokenForDiscordID } from "./query/user-map";
|
||||
import { app } from "./server/server";
|
||||
import { app, MountFallbackHandlers } from "./server/server";
|
||||
import { ClosePgConnection } from "./services/pg/db";
|
||||
import { RegisterSlashCommands } from "./slash-commands/register";
|
||||
import { VERSION_PRETTY } from "./version";
|
||||
@@ -101,6 +101,9 @@ void (async () => {
|
||||
|
||||
log.info(`Logged in successfully to ${client.guilds.cache.size} guilds.`);
|
||||
|
||||
// Mount the 404 + error fallbacks last.
|
||||
MountFallbackHandlers();
|
||||
|
||||
// Mount our express server.
|
||||
const server = app.listen(Env.PORT);
|
||||
|
||||
|
||||
@@ -159,18 +159,6 @@ app.post("/webhook", ValidateWebhookRequest, async (req, res) => {
|
||||
return res.sendStatus(statusCode);
|
||||
});
|
||||
|
||||
/**
|
||||
* 404 Handler. If something gets to this point, they haven't matched with anything.
|
||||
*
|
||||
* @name ALL *
|
||||
*/
|
||||
app.all("*", (_req, res) =>
|
||||
res.status(404).json({
|
||||
success: false,
|
||||
description: "Nothing found here.",
|
||||
}),
|
||||
);
|
||||
|
||||
interface ExpressJSONErr extends SyntaxError {
|
||||
status: number;
|
||||
message: string;
|
||||
@@ -209,6 +197,20 @@ const MainExpressErrorHandler: express.ErrorRequestHandler = (err, req, res, _ne
|
||||
});
|
||||
};
|
||||
|
||||
app.use(MainExpressErrorHandler);
|
||||
export function MountFallbackHandlers(): void {
|
||||
/**
|
||||
* 404 Handler. If something gets to this point, they haven't matched with anything.
|
||||
*
|
||||
* @name ALL *
|
||||
*/
|
||||
app.all("*", (_req, res) =>
|
||||
res.status(404).json({
|
||||
success: false,
|
||||
description: "Nothing found here.",
|
||||
}),
|
||||
);
|
||||
|
||||
app.use(MainExpressErrorHandler);
|
||||
}
|
||||
|
||||
log.info(`Starting express server on port ${Env.PORT}.`);
|
||||
|
||||
Reference in New Issue
Block a user