Skip to content

Commit 364c2fa

Browse files
committed
fix: add 404 page
1 parent 62d56ff commit 364c2fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/router.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const micro = require("micro")
12
const { router, get, post, patch, options } = require("microrouter")
23

34
const getDiffsEndpoint = require("./endpoints/get-diffs.js")
@@ -8,6 +9,8 @@ const getSampleEndpoint = require("./endpoints/get-sample.js")
89
const patchSampleEndpoint = require("./endpoints/patch-sample.js")
910
const downloadEndpoint = require("./endpoints/download-session.js")
1011

12+
const notfound = (req, res) => micro.send(res, 404)
13+
1114
module.exports = router(
1215
post("/api/session", postSessionEndpoint),
1316
options("/api/session", postSessionEndpoint),
@@ -18,5 +21,6 @@ module.exports = router(
1821
patch("/api/session/:session_id/sample/:sample_index", patchSampleEndpoint),
1922
get("/api/session/:session_id", getSessionEndpoint),
2023
patch("/api/session/:session_id", patchSessionEndpoint),
21-
options("/api/session/:session_id", patchSessionEndpoint)
24+
options("/api/session/:session_id", patchSessionEndpoint),
25+
get("/*", notfound)
2226
)

0 commit comments

Comments
 (0)