fix(striker-ui-api): make static files available through root

main
Tsu-ba-me 2 years ago
parent d8a2c77cf0
commit 9170f78650
  1. 13
      striker-ui-api/src/app.ts
  2. 1
      striker-ui-api/src/lib/consts/SERVER_PATHS.ts
  3. 10
      striker-ui-api/src/routes/index.ts
  4. 13
      striker-ui-api/src/routes/static.ts

@ -1,7 +1,7 @@
import cors from 'cors';
import express, { json } from 'express';
import { assertAuthentication } from './lib/assertAuthentication';
import { authenticationHandler } from './lib/assertAuthentication';
import passport from './passport';
import routes from './routes';
import { rrouters } from './lib/rrouters';
@ -20,13 +20,12 @@ app.use(sessionHandler);
app.use(passport.initialize());
app.use(passport.authenticate('session'));
const authenticationHandler = assertAuthentication();
rrouters(app, routes, {
rrouters(app, routes.private, {
assign: (router) => [authenticationHandler, router],
key: 'api',
route: '/api',
});
rrouters(app, routes, { key: 'auth' });
rrouters(app, routes, { key: 'echo' });
rrouters(app, routes.public, { route: '/api' });
app.use(routes.static);
export default app;

@ -37,6 +37,7 @@ const EMPTY_SERVER_PATHS: ServerPath = {
'striker-parse-os-list': {},
},
},
var: { www: { html: {} } },
};
const generatePaths = (

@ -10,11 +10,12 @@ import manifestRouter from './manifest';
import networkInterfaceRouter from './network-interface';
import serverRouter from './server';
import sshKeyRouter from './ssh-key';
import staticRouter from './static';
import upsRouter from './ups';
import userRouter from './user';
const routes = {
api: {
private: {
anvil: anvilRouter,
command: commandRouter,
fence: fenceRouter,
@ -28,8 +29,11 @@ const routes = {
ups: upsRouter,
user: userRouter,
},
auth: authRouter,
echo: echoRouter,
public: {
auth: authRouter,
echo: echoRouter,
},
static: staticRouter,
};
export default routes;

@ -0,0 +1,13 @@
import express from 'express';
import { SERVER_PATHS } from '../lib/consts';
const router = express.Router();
router.use(
express.static(SERVER_PATHS.var.www.html.self, {
extensions: ['htm', 'html'],
}),
);
export default router;
Loading…
Cancel
Save