From 20ad1957ae6a577b011e7888af95529b86970c62 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 6 Dec 2020 21:49:29 -0600 Subject: [PATCH] feat: http routes --- packages/http/src/server.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/http/src/server.js b/packages/http/src/server.js index 6b3b927..5532418 100644 --- a/packages/http/src/server.js +++ b/packages/http/src/server.js @@ -2,6 +2,7 @@ import {createReadStream} from 'fs'; import {createServer} from 'http'; import {join} from 'path'; +import {arrayFlatten} from '@latus/core'; import express from 'express'; import latusMiddleware from './latus'; @@ -21,6 +22,8 @@ export const createHttpServer = async (latus) => { app.use((req, res, next) => { latus.invokeMiddleware('@latus/http/request', req, res, next); }); + const routes = arrayFlatten(latus.invokeFlat('@latus/http/routes')); + routes.forEach(({method, path, handler}) => app[method](path, handler)); // Serve latus. app.use(latusMiddleware(latus)); app.use(express.static(join(__dirname, 'client')));