summaryrefslogtreecommitdiff
path: root/src/web.mjs
blob: cd875a0f500f8247f7ea00d4f177ce9d29497da8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import * as u from "./utils.mjs";
import { buildServer, defaultInterceptors } from "./hero.mjs";


const listProducts = req => ({ status: 200 });
const getProduct   = req => ({ status: 200 });
const getChat      = req => ({ status: 200, body: "something\n" });

const server = buildServer([
	[ "GET", "/products",     listProducts ],
	[ "GET", "/products/:id", getProduct   ],
	[ "GET", "/chat",         getChat   ],
], defaultInterceptors);

export const app = async udsPath => {
	await server.listen(udsPath);
	u.log({ type: "starting-server", udsPath });
};