feat: gave API an onStart()

pull/180/head
tycrek 2 years ago
parent 62b2bf953f
commit f302f56ac6
No known key found for this signature in database
GPG Key ID: FF8A54DCE404885A

@ -10,6 +10,7 @@ import tailwindcss from 'tailwindcss';
import helmet from 'helmet';
import { path, log, getTrueHttp, getTrueDomain } from './utils';
import { onStart as ApiOnStart } from './routers/api';
//#endregion
//#region Setup - Run first time setup if using Docker (pseudo-process, setup will be run with docker exec)
@ -105,6 +106,9 @@ ASS_FRONTEND.enabled && app.use(ASS_FRONTEND.endpoint, ASS_FRONTEND.router); //
// Upload router (has to come after custom frontends as express-busboy interferes with all POST calls)
app.use('/', ROUTERS.upload);
// API
app.use('/api', ApiOnStart());
// CSS
app.use('/css', epcss({
cssPath: path('tailwind.css'),

@ -8,6 +8,7 @@ import { Router, Request, Response, NextFunction } from 'express';
import { users } from '../auth';
import { data } from '../data';
const RouterApi = Router();
const RouterUser = Router();
const RouterResource = Router();
@ -20,3 +21,10 @@ const authMiddleware = (req: Request, res: Response, next: NextFunction) => {
? next()
: res.sendStatus(401);
};
export const onStart = () => {
RouterApi.use('/user', RouterUser);
RouterApi.use('/resource', RouterResource);
return RouterApi;
};

Loading…
Cancel
Save