import { Handler, Router } from '@/mission-control'; import { getBans, removeBan } from '~/db/admin/queries'; import withQuery from '~/middleware/withQuery'; import AdminBansPage from '~/views/admin/AdminBansPage'; const router = new Router(); router.use('/', (req, res, { tb }) => { const bans = getBans(); res.send(tb.include(AdminBansPage, { bans })); res.end(); }); router.use('/:origin', withQuery('confirm'), (req, res, { params }) => { if (req.query! === 'confirm') { const origin = decodeURIComponent(params.origin!); removeBan(origin); } res.redirect(`/admin/bans`); }); export default router;