Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private controllers(app: Application): void {
logger.debug('Configuring routes...');
// const controllers = [`${__dirname}/controllers/*`];
useExpressServer(app, {
controllers: [IndexController, ApiV2Controller, ApiV1Controller],
middlewares: [
// custom middlewares
Analytics,
NotFoundHandler,
ErrorHandler,
],
defaultErrorHandler: false,
});
}
setupControllers() {
const controllersPath = path.resolve('dist', 'controllers');
useExpressServer(this.app, {
controllerDirs: [ controllersPath ],
container: Container
});
}
private createApp(): Application {
const app = express();
const publicPath = join(process.cwd(), './public');
app.use('/public', compression(), express.static(publicPath));
useExpressServer(app, {
routePrefix: '/mock_api',
controllers: this.controllers()
});
return app;
}
setupControllers() {
const controllersPath = path.resolve('dist', 'controllers');
useExpressServer(this.app, {
controllerDirs: [ controllersPath ]
});
}
private initApplication() {
this.app.use(bodyParser.json(this.config.bodyParser));
this.app.use(compression());
useExpressServer(this.app, {
controllers: [join(__dirname, './controllers/render/RenderController.js')]
});
}
async initialize() {
useContainer(new ContextContainer(this.context))
const serv = express()
serv.use(cors())
this.app = useExpressServer(serv, {
routePrefix: '/api/v1',
controllers: [ConnectionsController, ServicesController],
middlewares: [ErrorMiddleware],
interceptors: [ResponseMiddleware],
defaultErrorHandler: false,
}) as Application
this.wsServer = new WebsocketServer({
port: 2136,
})
this.statusSubscription = this.context.serviceManager.statusSubject.subscribe(
el => {
this.broadcastPacket({
namespace: 'services',
mutation: SocketEvent.ServiceStatusUpdate,
const getTokenFromAction = (action: Action) => {
const clientAccessToken =
action.request.headers.cookie &&
parse(action.request.headers.cookie as any)[appAuthAccessTokenKey]
const clientIdToken =
action.request.headers.cookie &&
parse(action.request.headers.cookie as any)[appAuthIdTokenKey]
return {
clientAccessToken,
clientIdToken
}
}
configApi(app, {
authorizationChecker: async (
action: Action,
roles: ReadonlyArray
) => {
const tokenTuple = getTokenFromAction(action)
return auth0ServerValidationNoAngularFactory(
azNoAngular,
tokenTuple.clientAccessToken,
tokenTuple.clientIdToken
)
.pipe(
map(user => {
const uroles =
(user && (user as any)[process.env.AUTH0_ROLES_KEY as string]) ||
{}
const userRoles: ReadonlyArray = Object.keys(uroles).filter(
createApp() {
const app = express_1.default();
const publicPath = path_1.join(process.cwd(), './public');
app.use(serve_favicon_1.default(path_1.join(__dirname, '../favicon.ico')));
app.use('/public', compression_1.default(), express_1.default.static(publicPath));
const vendorPath = path_1.join(__dirname, '../../art-lib-react/dist/vendors/');
app.use('/static', compression_1.default(), express_1.default.static(vendorPath));
this.appTemplate(app);
routing_controllers_1.useExpressServer(app, {
routePrefix: '/mock_api',
controllers: this.controllers()
});
this.appIndexPage(app);
return app;
}
start() {