forked from Regexcellence/Regexcellence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (23 loc) · 986 Bytes
/
index.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
33
34
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
const mongoose = require('mongoose');
const MONGO_URI = process.env.MONGO_URI || require('./config').MONGO_URI;
// To ensure a test doesn't interrupt with a currently running server.
const port = process.env.NODE_ENV === 'test' ? 3001 : process.env.PORT || 3000;
app.set('port', port);
process.env.PWD = process.cwd();
const TARGET = process.env.npm_lifecycle_event;
if (TARGET !== 'devStart') {
app.use(express.static(path.join(process.env.PWD, 'build')));
}
const gitAuth = require('./server/github-auth/git-auth-handlers');
gitAuth(app);
const handleRequest = require('./server/handlers');
handleRequest(app);
mongoose.connect(MONGO_URI);
app.listen(port, () => { console.log(`Listening on http://localhost:${port}/`); });
exports = module.exports = app;