| Current Path : /proc/thread-self/root/home/deltalab/PMS/buy-button-generator/routes/ |
| Current File : //proc/thread-self/root/home/deltalab/PMS/buy-button-generator/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');
/* 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,
}));
// EXPORTS ==================================================
module.exports = router;