login / register ui

This commit is contained in:
biglyderv 2025-02-25 16:35:22 -05:00
parent ae511a3871
commit d1d2d08330
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
5 changed files with 158 additions and 7 deletions

31
init.js
View file

@ -1,31 +1,48 @@
import { importRouters } from "./lib.js";
const aliases = {
'/': '/walls/get/home'
};
const routers = {
'/you': './you.js'
}
function doAliases(app) {
for (let alias in aliases) {
app.all(alias, (req,res,next) => {
app.all(alias, (req, res, next) => {
res.redirect(aliases[alias])
})
}
}
function doInit(app) {
async function doInit(app) {
app.use((req, res, next) => {
let headerCtx = [
{ link: '/walls/get/home', icon: '/icon.svg', name: 'DervNet' },
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' } // fix icon
];
if (!res.auth || !res.auth.valid) {
headerCtx = [
{ link: '/walls/get/home', icon: '/icon.svg', name: 'DervNet' },
{ link: '/you/login', icon: '/walls.svg', name: 'Log in' }
];
}
res.ctx = {
mainPage: '404.ejs',
mainCtx: {},
headerCtx: [
{ link: '/walls/get/home', icon: '/icon.svg', name: 'DervNet' },
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' } // fix icon
]
headerCtx
};
next();
})
doAliases(app);
await importRouters(app,routers);
app.use('/api', (req, res, next) => {
res.send(res.ctx);
})