feat: add an index page
This commit is contained in:
parent
98a53051ee
commit
c06e655819
|
@ -1,12 +1,14 @@
|
||||||
import { FastifyPluginAsync } from 'fastify';
|
import { FastifyPluginAsync } from 'fastify';
|
||||||
import deleter from './delete.js';
|
import deleter from './delete.js';
|
||||||
import upload from './upload.js';
|
import upload from './upload.js';
|
||||||
|
import index from './indexpage.js';
|
||||||
import list from './list.js';
|
import list from './list.js';
|
||||||
import get from './get.js';
|
import get from './get.js';
|
||||||
|
|
||||||
export default (async function (fastify) {
|
export default (async function (fastify) {
|
||||||
await fastify.register(deleter);
|
await fastify.register(deleter);
|
||||||
await fastify.register(upload);
|
await fastify.register(upload);
|
||||||
|
await fastify.register(index);
|
||||||
await fastify.register(list);
|
await fastify.register(list);
|
||||||
await fastify.register(get);
|
await fastify.register(get);
|
||||||
} as FastifyPluginAsync);
|
} as FastifyPluginAsync);
|
||||||
|
|
|
@ -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);
|
Loading…
Reference in New Issue