-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
28 lines (24 loc) · 998 Bytes
/
server.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
// server to be run on heroku
// require("dotenv").load();
const express = require('express');
const app = express();
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
// res.header('if-none-match','no-match-for-this'); // was a potential fix for 304s on get requests
next();
});
app.disable('etag'); // fix for 304s on get requests
var path = require('path');
var favicon = require('serve-favicon');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var fs = require('fs');
require('./src/app_api/models/db');
var routesApi = require('./src/app_api/routes/index');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use("/api", routesApi);
app.use(express.static(__dirname + '/dist'));
module.exports = app.listen(process.env.PORT || 8080);