feat: add an index page

This commit is contained in:
b1ek 2024-05-11 21:54:41 +10:00
parent 98a53051ee
commit c06e655819
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 31 additions and 0 deletions

View File

@ -1,12 +1,14 @@
import { FastifyPluginAsync } from 'fastify';
import deleter from './delete.js';
import upload from './upload.js';
import index from './indexpage.js';
import list from './list.js';
import get from './get.js';
export default (async function (fastify) {
await fastify.register(deleter);
await fastify.register(upload);
await fastify.register(index);
await fastify.register(list);
await fastify.register(get);
} as FastifyPluginAsync);

29
src/routes/indexpage.ts Normal file
View File

@ -0,0 +1,29 @@
import { FastifyPluginAsync } from 'fastify';
const page = `<!DOCTYPE html>
<html>
<head>
<title>Backup server</title>
<style>*{background:#111;color:white}a{color:#abf}</style>
</head>
<body>
<h1>You have reached the backup server!</h1>
<p>This is the backup server! If you are a regular user, you wouldn't find this place very interesting and might as well close this page now.</p>
<p>If you are a sysadmin, please refer to <a href='https://git.blek.codes/blek/backups.git'>API docs</a> for more info</p>
</body>
</html>
`
.replaceAll('\n', '')
.replaceAll(/ +/gm, ' ')
.replaceAll(' <', '<');
export default (async function (fastify) {
fastify.get('/', async (_req, rep) => {
rep.type('text/html; charset=utf8');
return page;
});
fastify.get('/favicon.ico', async (req, rep) => {
rep.status(404);
return '';
});
} as FastifyPluginAsync);