-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (24 loc) · 938 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const mongoose = require('mongoose');
//There is logic in Config to determin the enviroment settings
const CONFIG = require('./config/config');
mongoose.connect(CONFIG.DB_AUTH, { useNewUrlParser: true });
const indexRouter = require('./routes/index');
const exampleRouter = require('./routes/example');
const app = express();
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
//MAKE SURE THIS IS RESTRICTED IN PRODUCTION
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", process.env.HEADER_ACCESS_CONTROL_ALLOW_ORIGIN);
next();
});
app.use('/', indexRouter);
app.use('/example', exampleRouter);
module.exports = app;