| Current Path : /home/deltalab/PMS/sms-connector/routes/ |
| Current File : //home/deltalab/PMS/sms-connector/routes/api.js |
const express = require('express');
const router = express.Router();
const { graphqlHTTP } = require('express-graphql');
const { graphQLSchemas } = require('./../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('In Auth middleware');
//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;