chore(project) rename main directory

This commit is contained in:
Benjamin Wegener
2024-04-02 23:24:31 +00:00
parent 9147658f30
commit a12d7f3343
10 changed files with 0 additions and 0 deletions

30
lib/index.js Normal file
View File

@@ -0,0 +1,30 @@
import WetSock from './WetSock';
import { resolve } from 'path';
const wetsock = new WetSock();
const server = Bun.serve({
port: process.env.APP_PORT || 43_069,
fetch(req, server) {
const url = new URL(req.url);
if(url.pathname == '/chat') return wetsock.handleUpgrade(req, server);
if(url.pathname == '/client.js') {
const filePath = resolve(__dirname, 'WetSock', 'Client', 'Client.js');
const file = Bun.file(filePath);
return new Response(file);
}
const filePath = resolve(__dirname, 'views', 'index.html');
const file = Bun.file(filePath);
return new Response(file);
},
websocket: {
open: wetsock.handleOpen.bind(wetsock),
close: wetsock.handleClose.bind(wetsock),
message: wetsock.handleMessage.bind(wetsock),
drain: wetsock.handleDrain.bind(wetsock),
}
});
wetsock.start(server);