flesh out frontend
This commit is contained in:
36
src/Web.ts
36
src/Web.ts
@@ -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 = () => {
|
||||
|
Reference in New Issue
Block a user