logs and add healthcheck
This commit is contained in:
parent
bcd0035ad5
commit
f02385986e
12
index.ts
12
index.ts
@ -17,7 +17,12 @@ app.use('/assets', express.static('assets'));
|
||||
|
||||
let visitCount = (await Bun.file(dataPath).json())['visits'] as number || 0;
|
||||
|
||||
app.get('/', (_, res) => {
|
||||
app.get('/healthcheck', (req, res) => {
|
||||
res.send('Healthy');
|
||||
});
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
console.log(req.headers['user-agent']);
|
||||
res.render('index',
|
||||
{
|
||||
visitCount
|
||||
@ -39,6 +44,11 @@ app.get('/cache-me.webp', (_, res) => {
|
||||
res.sendFile(Path.join(import.meta.dir, 'assets', 'webp', 'cache-me.webp'));
|
||||
});
|
||||
|
||||
app.all('*', (req, res) => {
|
||||
console.log(`404: ${req.url} requested by ${req.ip} "${req.headers['user-agent']}"`);
|
||||
res.redirect('/');
|
||||
});
|
||||
|
||||
const webserver = app.listen(port, () => console.log(`jakehurwitzisabitch.com running on port ${port}`));
|
||||
|
||||
async function saveVisits() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user