diff --git a/backend/app.ts b/backend/app.ts index 52c290f..0712164 100644 --- a/backend/app.ts +++ b/backend/app.ts @@ -114,12 +114,10 @@ async function main() { 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)); - // ! I did not want to do it like this how tf did I back myself into this shit - app.get('/admin', (req, res) => res.render('admin', { version: App.pkgVersion })); - - // Routing + // Routers app.use('/setup', (await import('./routers/setup.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('/', (await import('./routers/index.js')).router); diff --git a/backend/routers/admin.ts b/backend/routers/admin.ts new file mode 100644 index 0000000..b3c55f0 --- /dev/null +++ b/backend/routers/admin.ts @@ -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 }; diff --git a/common/fix-frontend-js.js b/common/fix-frontend-js.js index d3f4439..401a564 100644 --- a/common/fix-frontend-js.js +++ b/common/fix-frontend-js.js @@ -7,7 +7,8 @@ const FILES = { suffix: '.mjs', pages: [ 'setup', - 'login' + 'login', + 'admin', ] }; diff --git a/frontend/admin.mts b/frontend/admin.mts new file mode 100644 index 0000000..62f94c6 --- /dev/null +++ b/frontend/admin.mts @@ -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')); diff --git a/views/admin.pug b/views/admin.pug index 086cff4..65b04af 100644 --- a/views/admin.pug +++ b/views/admin.pug @@ -4,4 +4,6 @@ block title block section span admin block content - h1.text-3xl Coming soon. \ No newline at end of file + h1.text-3xl Coming soon. + + script(src='/admin/ui.js')