Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const bodyParser = require('body-parser');
- const consign = require('consign');
- const expressValidator = require('express-validator');
- const multiparty = require('connect-multiparty');
- const cors = require('cors');
- const app = express();
- app.use(bodyParser.json())
- app.use(bodyParser.urlencoded({extended: false}));
- app.use(expressValidator());
- app.use(multiparty());
- app.use(function(req, res, next) {
- res.header("Access-Control-Allow-Origin", "*");
- res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
- res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
- next();
- });
- /*app.use( (req, res, next) => {
- // Website you wish to allow to connect
- res.setHeader('Access-Control-Allow-Origin', '*');
- // Request methods you wish to allow
- res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
- // Request headers you wish to allow
- res.setHeader('Content-Type', 'application/json');
- // Set to true if you need the website to include cookies in the requests sent
- // to the API (e.g. in case you use sessions)
- res.setHeader('Access-Control-Allow-Credentials', true);
- // Pass to next layer of middleware
- next();
- });
- */
- consign()
- .include('./app/routers')
- .then('./app/controllers')
- .then('./app/models/Schemas')
- .then('./config/dbConnection.js')
- .then('./app/models')
- .into(app);
- module.exports = app;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement