feat: http routes
This commit is contained in:
parent
e911c2e6fd
commit
20ad1957ae
|
@ -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')));
|
||||
|
|
Loading…
Reference in New Issue
Block a user