feat: added base implementation of admin routing

pull/239/head
Josh Moore 1 year ago
parent 701c808f7a
commit 72a58295ae

@ -114,12 +114,10 @@ async function main() {
app.get('/.ass.host', (req, res) => res.type('text').send(req.ass.host)); app.get('/.ass.host', (req, res) => res.type('text').send(req.ass.host));
app.get('/.ass.version', (req, res) => res.type('text').send(req.ass.version)); app.get('/.ass.version', (req, res) => res.type('text').send(req.ass.version));
// ! I did not want to do it like this how tf did I back myself into this shit // Routers
app.get('/admin', (req, res) => res.render('admin', { version: App.pkgVersion }));
// Routing
app.use('/setup', (await import('./routers/setup.js')).router); app.use('/setup', (await import('./routers/setup.js')).router);
app.use('/login', (await import('./routers/login.js')).router); app.use('/login', (await import('./routers/login.js')).router);
app.use('/admin', (await import('./routers/admin.js')).router);
app.use('/api', (await import('./routers/api.js')).router); app.use('/api', (await import('./routers/api.js')).router);
app.use('/', (await import('./routers/index.js')).router); app.use('/', (await import('./routers/index.js')).router);

@ -0,0 +1,16 @@
import { path } from '@tycrek/joint';
import { Router, json as BodyParserJson } from 'express';
import { log } from '../log';
import { UserConfig } from '../UserConfig';
import { App } from '../app';
const router = Router({ caseSensitive: true });
// Static routes
router.get('/', (req, res) => !UserConfig.ready ? res.redirect('/') : res.render('admin', { version: App.pkgVersion }));
router.get('/ui.js', (req, res) => !UserConfig.ready ? res.send('') : res.type('text/javascript').sendFile(path.join('dist-frontend/admin.mjs')));
router.post('/', BodyParserJson(), async (req, res) => {
});
export { router };

@ -7,7 +7,8 @@ const FILES = {
suffix: '.mjs', suffix: '.mjs',
pages: [ pages: [
'setup', 'setup',
'login' 'login',
'admin',
] ]
}; };

@ -0,0 +1,4 @@
import { SlInput, SlButton } from '@shoelace-style/shoelace';
// * Wait for the document to be ready
document.addEventListener('DOMContentLoaded', () => console.log('Admin page loaded'));

@ -5,3 +5,5 @@ block section
span admin span admin
block content block content
h1.text-3xl Coming soon. h1.text-3xl Coming soon.
script(src='/admin/ui.js')

Loading…
Cancel
Save