Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move catch-all route-not-found handler to root #440

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
default = pkgs.mkShell {
buildInputs = with pkgs; [
nixpkgs-fmt
nodejs
gnumake
] ++ buildInputs ++ nativeBuildInputs;

Expand Down
5 changes: 3 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ process.on('uncaughtException', (err, origin) => {
*/
app.get('/healthz', (_req, res) => res.json(ReasonPhrases.OK));

app.use('/', (_req, res) => {
return sendError(res, 'bad-request');
// all other routes should throw 404 not found
app.use('*', (_req, res) => {
return sendError(res, 'route-not-found');
});

export { app };
6 changes: 0 additions & 6 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { sendError } from '@/errors';
import * as express from 'express';
import nocache from 'nocache';
import env from './env';
Expand Down Expand Up @@ -40,9 +39,4 @@ env(router);

router.use(oauthProviders);

// all other routes should throw 404 not found
router.use('*', (rwq, res) => {
return sendError(res, 'route-not-found');
});

export default router;