Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import express from 'express';
import http from 'http';
import jsonapiSerializer from 'jsonapi-serializer';
import logger from 'morgan';
import { globalAccept, globalContentType, mainRoutes, port } from './constants/Globals';
import router from './routes/routes';
import './services/CheckEnvVars';
import { isValid, NotFoundhandler, onError } from './services/Helpers';
// const declaration
const app = express();
const JSONAPIError = jsonapiSerializer.Error;
// middleware
app.use(logger('dev'));
app.use(bodyParser.json({ type: globalContentType }));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.header('Content-Type', globalContentType);
res.header('Accept', globalContentType);
res.removeHeader('X-Powered-By');
next();
});