diff --git a/src/ass.ts b/src/ass.ts index 5b41b6b..445e893 100644 --- a/src/ass.ts +++ b/src/ass.ts @@ -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'), diff --git a/src/routers/api.ts b/src/routers/api.ts index d1c5765..c028130 100644 --- a/src/routers/api.ts +++ b/src/routers/api.ts @@ -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; +};