You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RTL/server/utils/csrf.ts

24 lines
803 B
TypeScript

import csurf from 'csurf/index.js';
import { Application } from 'express';
import { Logger, LoggerService } from './logger.js';
import { Common, CommonService } from './common.js';
class CSRF {
public csrfProtection = csurf({ cookie: true });
public logger: LoggerService = Logger;
public common: CommonService = Common;
public mount(app: Application): Application {
this.logger.log({ selectedNode: this.common.initSelectedNode, level: 'INFO', fileName: 'CSRF', msg: 'Setting up CSRF..' });
if (process.env.NODE_ENV !== 'development') {
app.use((req, res, next) => this.csrfProtection(req, res, next));
}
this.logger.log({ selectedNode: this.common.initSelectedNode, level: 'INFO', fileName: 'CSRF', msg: 'CSRF Set' });
return app;
};
}
export default new CSRF;