start playing with websockets

This commit is contained in:
dylan
2024-04-03 20:29:27 -07:00
parent df5423b294
commit f9e21db529
11 changed files with 554 additions and 152 deletions

View File

@@ -1,8 +1,9 @@
// Import the framework and instantiate it
import Fastify from 'fastify'
import fastifyStatic from '@fastify/static'
import {fastifyWebsocket} from '@fastify/websocket';
import { routeList } from "./routelist.ts";
import { route } from "./util/routewrap.ts";
import { attachRoute } from "./util/routewrap.ts";
import { git } from './util/git.ts';
import path from "path";
import {fileURLToPath} from 'url';
@@ -17,13 +18,15 @@ const server = Fastify({
logger: true
});
server.register(fastifyWebsocket);
server.register(fastifyStatic, {
root: new URL('public', import.meta.url).toString().slice("file://".length),
prefix: '/',
});
routeList.forEach(firRoute => {
server.route(route(firRoute));
attachRoute(server, firRoute);
});
server.setNotFoundHandler((req, res) => {