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.
18 lines
524 B
JavaScript
18 lines
524 B
JavaScript
import csurf from 'csurf/index.js';
|
|
import { Logger } from './logger.js';
|
|
class CSRF {
|
|
constructor() {
|
|
this.csrfProtection = csurf({ cookie: true });
|
|
this.logger = Logger;
|
|
}
|
|
mount(app) {
|
|
this.logger.log({ selectedNode: null, level: 'DEBUG', fileName: 'CSRF', msg: 'Setting up CSRF.' });
|
|
if (process.env.NODE_ENV !== 'development') {
|
|
app.use((req, res, next) => this.csrfProtection(req, res, next));
|
|
}
|
|
return app;
|
|
}
|
|
;
|
|
}
|
|
export default new CSRF;
|