forked from pickle69420/picklebox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (28 loc) · 740 Bytes
/
Copy pathindex.js
File metadata and controls
36 lines (28 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import createBareServer from '@tomphttp/bare-server-node';
import express from 'express';
import http from 'node:http';
import { handler } from './build/handler.js';
const httpServer = http.createServer();
const app = express();
app.use(handler);
const bareServer = createBareServer('/bare/');
httpServer.on('request', (req, res) => {
if (bareServer.shouldRoute(req)) {
bareServer.routeRequest(req, res);
} else {
app(req, res);
}
});
httpServer.on('upgrade', (req, socket, head) => {
if (bareServer.shouldRoute(req)) {
bareServer.routeUpgrade(req, socket, head);
} else {
socket.end();
}
});
httpServer.on('listening', () => {
console.log('PickleHub listening on port 3000');
});
httpServer.listen({
port: 3000,
});