| Current Path : /proc/thread-self/root/proc/thread-self/root/home/deltalab/PMS/pim-connector/routes/ |
| Current File : //proc/thread-self/root/proc/thread-self/root/home/deltalab/PMS/pim-connector/routes/api.js |
const express = require('express');
const router = express.Router();
const { graphqlHTTP } = require('express-graphql');
const { graphQLSchemas } = require('./../models/graphql/schemas');
/* Auth gate-keeping */
router.use('/', function(req, res, next){
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
console.log('Processing request');
//console.log(req.body);
/* Here it should block the request if the token in the Authorization header is not valid */
// Check token exp date
// Check token signature
// Check role
/* Go on with the next middleware */
next();
});
/* GraphQl endpoint */
router.use('/', graphqlHTTP({
schema: graphQLSchemas,
graphiql: false,
}));
module.exports = router;