summaryrefslogtreecommitdiff
path: root/src/web.mjs
blob: 3ca2544b67ed566097f86e1ecb419d7025eef152 (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 * as hero from "./hero.mjs";

const listProducts = req => ({ status: 200 });
const getProduct   = req => ({ status: 200, body: "PRODUTO" });
const getSocket    = req => ({ status: 200, body: "SOCKET"  });


const server = hero.buildServer("papo", [
	[ "GET", "/api/products",     listProducts ],
	[ "GET", "/api/products/:id", getProduct   ],
	[ "GET", "/api/socket",       getSocket    ],
]);

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