initial work on client-side templating

This commit is contained in:
knotteye
2020-10-14 00:03:45 -05:00
parent 99879fd91e
commit 57d0b0f856
3 changed files with 47 additions and 2 deletions

View File

@@ -56,11 +56,12 @@ async function init(){
}
app.disable('x-powered-by');
//site handlers
await initSite(config['satyr']['registration']);
//await initSite(config['satyr']['registration']);
//api handlers
await initAPI();
//static files if nothing else matches first
app.use(express.static(config['http']['directory']));
await initFE();
//404 Handler
app.use(function (req, res, next) {
if(tryDecode(req.cookies.Authorization)) {
@@ -73,6 +74,12 @@ async function init(){
server.listen(config['http']['port']);
}
async function initFE(){
app.get('*', (req, res) => {
res.sendFile(process.cwd()+'/'+config['http']['directory']+'/index.html');
});
}
async function newNick(socket, skip?: boolean, i?: number) {
if(socket.handshake.headers['cookie'] && !skip){
let c = await parseCookie(socket.handshake.headers['cookie']);