This repository has been archived by the owner on Mar 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
68 lines (54 loc) · 2.3 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// requirements
var express = require('express');
var mongoose = require('mongoose');
var morgan = require('morgan');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var path = require('path');
var colors = require('colors');
var cors = require('cors');
var async = require('async');
var bcrypt = require('bcryptjs');
var moment = require('moment');
var request = require('request');
var qs = require('querystring');
var jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens
var app = express();
// global modules
var helpers = require('./backend/helpers.js');
//env vars
var port = process.env.PORT || 3000;
var APP_URL = process.env.APP_URL;
var MONGOLAB_URI = process.env.MONGOLAB_URI;
var MAILGUN_API = process.env.MAILGUN_API;
var MAILGUN_DOMAIN = process.env.MAILGUN_DOMAIN;
var TOKEN_SECRET = process.env.TOKEN_SECRET;
//boring logging and parsing
app.use(express.static(__dirname + '/public')); // sets the static files location to public
app.use(morgan('dev')); // log with Morgan
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.text());
app.use(bodyParser.json({ type: 'application/vnd.api+json'}));
app.use(methodOverride());
app.use(cors());
//mongodb
mongoose.connect(MONGOLAB_URI);
mongoose.connection.on('error', function(err) {
console.log('Error: Could not connect to MongoDB. Did you forget to run `mongod`?'.red);
});
//authentication
//routes
var auth = require('./backend/routes.auth.js')(app);
var org = require('./backend/routes.orgs.js')(app);
var project = require('./backend/routes.projects.js')(app);
var issue = require('./backend/routes.issues.js')(app);
var tag = require('./backend/routes.tags.js')(app);
var field = require('./backend/routes.fields.js')(app);
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
res.setHeader('Last-Modified', (new Date()).toUTCString());
});
// go go inspector gadget
app.listen(port);
console.log('App listening on port ' + port);