diff --git a/.gitignore b/.gitignore index 09ebe8b6..c7b776a9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules **/.DS_store .env +.vs/ \ No newline at end of file diff --git a/NewFile b/NewFile new file mode 100644 index 00000000..e69de29b diff --git a/client/404.html b/client/404.html new file mode 100644 index 00000000..85df60e1 --- /dev/null +++ b/client/404.html @@ -0,0 +1,76 @@ + + + + + QB Reader + + + + + + + + + + + + + + + + +
+

Page Not Found

+
+

Rarely-used examples of these objects are named "Early Hints", "Variant Also Negotiates" and "Non-Authoritative Information". A 2016 proposal by Tim Bray to create a new one of these objects ends with the acknowledgement, "Thanks also to Ray Bradbury". That proposed object is named "Unavailable For Legal Reasons". An unofficial one of these objects used by Twitter's API is named for a quote from Demolition Man, "Enhance your calm". A Google easter egg produces one of these objects with the note, "The requested entity body is short and stout", in reference to a joke (*) "Coffee Pot Control Protocol" that introduced one of these things called "I'm a teapot". The 300 series of these things indicate a redirection, while the 200 series indicates success. For 10 points, identify these three-digit identifiers that include "502 Bad Gateway" and "404 Not Found".

+
+

ANSWER: HTTP status codes [accept HTTP error codes; accept HTTP codes; prompt on "HTTP responses" with "what part of the response?"; prompt on "status codes" or "error codes" with "under what protocol?"; anti-prompt on specific codes like "404 Not Found" with "can you be less specific?"]

+
+ + + \ No newline at end of file diff --git a/routes/index.js b/routes/index.js index f9d6d892..f625e524 100644 --- a/routes/index.js +++ b/routes/index.js @@ -7,7 +7,11 @@ import userRouter from './user.js'; import webhookRouter from './api/webhook.js'; import express, { Router } from 'express'; +import { fileURLToPath } from 'url'; +import path from 'path'; + const router = Router(); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); router.get('/*.scss', (req, res) => { res.sendFile(req.url, { root: './scss' }); @@ -16,11 +20,11 @@ router.get('/*.scss', (req, res) => { /** * Redirects: */ -router.get('/api-info', (req, res) => res.redirect('/api-docs')); -router.get('/bonuses', (req, res) => res.redirect('/singleplayer/bonuses')); -router.get('/db', (req, res) => res.redirect('/database')); -router.get('/tossups', (req, res) => res.redirect('/singleplayer/tossups')); -router.get('/user', (req, res) => res.redirect('/user/login')); +router.get('/api-info', (_req, res) => res.redirect('/api-docs')); +router.get('/bonuses', (_req, res) => res.redirect('/singleplayer/bonuses')); +router.get('/db', (_req, res) => res.redirect('/database')); +router.get('/tossups', (_req, res) => res.redirect('/singleplayer/tossups')); +router.get('/user', (_req, res) => res.redirect('/user/login')); /** * Routes: @@ -36,4 +40,11 @@ router.use('/webhook', webhookRouter); router.use(express.static('client', { extensions: ['html'] })); router.use(express.static('node_modules')); +/** + * 404 Error handler + */ +router.use((_req, res) => { + res.status(404).sendFile(path.join(__dirname, '../client', '404.html')); +}); + export default router;