flesh out frontend

This commit is contained in:
2025-01-11 03:14:02 -05:00
parent 0abf129fcc
commit f02676ba2e
9 changed files with 870 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
import * as http from "http";
import crypto from 'crypto';
import type { Express } from "express";
import express, { application } from 'express';
@@ -23,13 +24,44 @@ class Web {
app.set('trust proxy', 1);
app.set('view engine', 'ejs');
app.set('view options', { outputFunctionName: 'echo' });
app.use('/assets', express.static('assets'));
app.use('/assets', express.static('assets', { maxAge: '30 days' }));
app.use((_req, res, next) => {
crypto.randomBytes(32, (err, randomBytes) => {
if (err) {
console.error(err);
next(err);
} else {
res.locals.cspNonce = randomBytes.toString("hex");
next();
}
});
});
app.get('/', (_, res) => {
res.render('index', {
page: {
title: 'Archery',
titlesuffix: 'Dashboard',
description: 'PKGBUILD central'
}
});
});
app.get('/build/?', (_, res) => {
res.render('build', {
page: {
title: 'Archery',
titlesuffix: 'New Build',
description: 'Kick off a build'
}
});
});
app.get('/healthcheck', (_, res) => {
res.send('Healthy');
});
this._webserver = app.listen(port, () => console.log(`archy-build-thing is running on port ${port}`));
this._webserver = app.listen(port, () => console.log(`archery is running on port ${port}`));
}
close = () => {