I have been trying to implement the csurf module within my es6 method, but I am encountering errors in setting it up properly. I have experimented with different ways of declaring it without success and I am unsure of what the issue might be in terms of syntax. Any help would be greatly appreciated.
!--- trouble
/code/server/api/index.js:46 var csrfProtection1 = csrf({ cookie: true }); ^
ReferenceError: csrf is not defined
!------- issue
import { Router } from 'express';
import facets from './facets';
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import csurf from 'csurf';
let csrfProtection = csrf({ cookie: true });
export default function() {
/*var csrfProtection = csrf({ cookie: true })
var parseForm = bodyParser.urlencoded({ extended: false })*/
console.log(csrfProtection); //undefined
var api = Router();
// mount the facets resource
api.use('/facets', facets);
// perhaps expose some API metadata at the root
api.get('/', (req, res) => {
res.json({
version : '1.0'
});
});
return api;
}