From 033ceb43ba6cd0191a99e64270079cbb99ded3c4 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 6 Mar 2024 20:02:18 -0300 Subject: src/hero.mjs: Change server.listen() to receive no arguments --- src/web.mjs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/web.mjs') diff --git a/src/web.mjs b/src/web.mjs index 23ae5ff..4c3e621 100644 --- a/src/web.mjs +++ b/src/web.mjs @@ -6,13 +6,26 @@ const getProduct = req => ({ status: 200, body: "PRODUTO" }); const getSocket = req => ({ status: 200, body: "SOCKET" }); -const server = hero.buildServer("papo", [ +const name = "papo"; + +const routes = [ [ "GET", "/api/products", listProducts ], [ "GET", "/api/products/:id", getProduct ], [ "GET", "/api/socket", getSocket ], -]); +]; -export const app = async (...args) => { - await server.listen(...args); - hero.log.info({ type: "starting-server", args }); +export const app = async (socket, pipe) => { + const server = hero.buildServer({ + name, + routes, + socket, + pipe, + }); + await server.listen(); + hero.log.info({ + type: "starting-server", + name, + socket, + pipe, + }); }; -- cgit v1.2.3