fix(striker-ui-api): add flag to toggle API endpoint guard
This commit is contained in:
parent
be82c6e267
commit
9b13c77752
@ -1,6 +1,8 @@
|
|||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import express, { json } from 'express';
|
import express, { json } from 'express';
|
||||||
|
|
||||||
|
import { GUARD_API } from './lib/consts';
|
||||||
|
|
||||||
import { guardApi, passport, session } from './middlewares';
|
import { guardApi, passport, session } from './middlewares';
|
||||||
import routes from './routes';
|
import routes from './routes';
|
||||||
import { rrouters } from './lib/rrouters';
|
import { rrouters } from './lib/rrouters';
|
||||||
@ -25,7 +27,7 @@ export default (async () => {
|
|||||||
app.use(passport.authenticate('session'));
|
app.use(passport.authenticate('session'));
|
||||||
|
|
||||||
rrouters(app, routes.private, {
|
rrouters(app, routes.private, {
|
||||||
assign: (router) => [guardApi, router],
|
assign: GUARD_API ? (router) => [guardApi, router] : undefined,
|
||||||
route: '/api',
|
route: '/api',
|
||||||
});
|
});
|
||||||
rrouters(app, routes.public, { route: '/api' });
|
rrouters(app, routes.public, { route: '/api' });
|
||||||
|
@ -11,6 +11,13 @@ export const DEFAULT_JOB_PROGRESS: number = Number.parseInt(
|
|||||||
process.env.DEFAULT_JOB_PROGRESS ?? '0',
|
process.env.DEFAULT_JOB_PROGRESS ?? '0',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles whether to guard API endpoints with session information.
|
||||||
|
*/
|
||||||
|
export const GUARD_API = process.env.GUARD_API
|
||||||
|
? process.env.GUARD_API === 'true'
|
||||||
|
: true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Port to use by the express app.
|
* Port to use by the express app.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user