-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be6ada3
commit f7fb1c0
Showing
14 changed files
with
12 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,28 @@ | ||
import isAdmin from '../../database/account-info/is-admin.js'; | ||
import { checkToken } from '../../server/authentication.js'; | ||
|
||
import categoryReportsRouter from './category-reports.js'; | ||
import geowordRouter from './geoword.js'; | ||
import leaderboardRouter from './leaderboard.js'; | ||
|
||
import { Router } from 'express'; | ||
|
||
const router = Router(); | ||
|
||
router.use(async (req, res, next) => { | ||
const { username, token } = req.session; | ||
|
||
if (!checkToken(username, token)) { | ||
delete req.session; | ||
res.redirect('/user/login?' + encodeURIComponent(req.originalUrl)); | ||
return; | ||
} | ||
|
||
const admin = await isAdmin(username); | ||
|
||
if (!admin) { | ||
res.redirect('/user/login'); | ||
return; | ||
return res.redirect('/user/login'); | ||
} | ||
|
||
next(); | ||
}); | ||
|
||
router.use('/category-reports', categoryReportsRouter); | ||
router.use('/geoword', geowordRouter); | ||
router.use('/leaderboard', leaderboardRouter); | ||
|
||
router.get('/', (req, res) => { | ||
res.sendFile('index.html', { root: './client/admin' }); | ||
}); | ||
|
||
export default router; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,41 @@ | ||
import aboutRouter from './about/index.js'; | ||
import adminRouter from './admin/index.js'; | ||
import apiRouter from './api/index.js'; | ||
import apiDocsRouter from './api-docs.js'; | ||
import authRouter from './auth/index.js'; | ||
import backupsRouter from './backups.js'; | ||
import databaseRouter from './database.js'; | ||
import frequencyListRouter from './frequency-list.js'; | ||
import geowordRouter from './geoword/index.js'; | ||
import multiplayerRouter from './multiplayer.js'; | ||
import settingsRouter from './settings.js'; | ||
import singleplayerRouter from './singleplayer/index.js'; | ||
import userRouter from './user.js'; | ||
import webhookRouter from './api/webhook.js'; | ||
|
||
import { Router } from 'express'; | ||
import express, { Router } from 'express'; | ||
const router = Router(); | ||
|
||
router.get('/', (req, res) => { | ||
res.sendFile('index.html', { root: './client' }); | ||
}); | ||
|
||
router.get('/react(-dom)?/umd/*.js', (req, res) => { | ||
res.sendFile(req.url, { root: './node_modules' }); | ||
}); | ||
|
||
router.get('/react-highlight-words/build/static/*.js', (req, res) => { | ||
res.sendFile(req.url, { root: './node_modules' }); | ||
}); | ||
|
||
router.get('/node_modules/*.scss', (req, res) => { | ||
res.sendFile(req.url.substring(13), { root: './node_modules' }); | ||
}); | ||
|
||
router.get('/*.css', (req, res) => { | ||
res.sendFile(req.url, { root: './client' }); | ||
}); | ||
|
||
router.get('/*.ico', (req, res) => { | ||
res.sendFile(req.url, { root: './client' }); | ||
}); | ||
|
||
router.get('/*.js', (req, res) => { | ||
res.sendFile(req.url, { root: './client' }); | ||
}); | ||
|
||
router.get('/*.jsx', (req, res) => { | ||
res.sendFile(req.url, { root: './client' }); | ||
}); | ||
|
||
router.get('/*.map', (req, res) => { | ||
res.sendFile(req.url, { root: './client' }); | ||
}); | ||
|
||
router.get('/*.png', (req, res) => { | ||
res.sendFile(req.url, { root: './client' }); | ||
}); | ||
|
||
router.get('/*.scss', (req, res) => { | ||
res.sendFile(req.url.substring(5), { root: './scss' }); | ||
res.sendFile(req.url, { root: './scss' }); | ||
}); | ||
|
||
/** | ||
* Redirects: | ||
*/ | ||
router.get('/*.html', (req, res) => { | ||
res.redirect(req.url.substring(0, req.url.length - 5)); | ||
}); | ||
|
||
router.get('/api-info', (req, res) => { | ||
res.redirect('/api-docs'); | ||
}); | ||
|
||
router.get('/bonuses', (_req, res) => { | ||
res.redirect('/singleplayer/bonuses'); | ||
}); | ||
|
||
router.get('/database', (_req, res) => { | ||
res.redirect('/db'); | ||
}); | ||
|
||
router.get('/index', (req, res) => { | ||
res.redirect('/'); | ||
}); | ||
|
||
router.get('/tossups', (req, res) => { | ||
res.redirect('/singleplayer/tossups'); | ||
}); | ||
|
||
router.get('/users', (req, res) => { | ||
res.redirect(`/user${req.url}`); | ||
}); | ||
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: | ||
*/ | ||
|
||
router.use('/about', aboutRouter); | ||
router.use('/admin', adminRouter); | ||
router.use('/api', apiRouter); | ||
router.use('/api-docs', apiDocsRouter); | ||
router.use('/auth', authRouter); | ||
router.use('/backups', backupsRouter); | ||
router.use('/db', databaseRouter); | ||
router.use('/frequency-list', frequencyListRouter); | ||
router.use('/geoword', geowordRouter); | ||
router.use('/multiplayer', multiplayerRouter); | ||
router.use('/settings', settingsRouter); | ||
router.use('/singleplayer', singleplayerRouter); | ||
router.use('/user', userRouter); | ||
router.use('/webhook', webhookRouter); | ||
|
||
router.use((req, res) => { | ||
res.sendFile(req.url, { root: './client' }); | ||
}); | ||
router.use(express.static('client', { extensions: ['html'] })); | ||
router.use(express.static('node_modules')); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.