summaryrefslogtreecommitdiff
path: root/src/web.mjs
blob: 5128a1e0f697ce6183672859ecc33e5ed3481f5b (plain) (blame)
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
import * as u    from "./utils.mjs";
import * as hero from "./hero.mjs";


const name = "papo";

const newConnection = (req, ws) => {
	// console.log({ ws, req });
	// ws.on("error", console.error);
	// ws.on("message", x => console.log(x.toString()));
	// ws.send("hello from the server");
};

const routes = [
	[ "WEBSOCKET", "/api/socket", newConnection ],
];

export const app = async (socket, pipe) => {
	const server = hero.buildServer({
		name,
		routes,
		socket,
		pipe,
	});
	await server.start();
	hero.log.info({
		type: "starting-server",
		name,
		socket,
		pipe,
	});
};