forked from techx/quill
-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
50 lines (35 loc) · 1.4 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Load the dotfiles.
require('dotenv').load({silent: true});
var express = require('express');
// Middleware!
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var morgan = require('morgan');
var mongoose = require('mongoose');
var port = process.env.PORT || 3000;
var database = process.env.DATABASE || process.env.MONGODB_URI || "mongodb://localhost:27017";
var settingsConfig = require('./config/settings');
var adminConfig = require('./config/admin');
var forumConfig = require('./config/forum');
var updatesConfig = require('./config/updates');
var app = express();
// Connect to mongodb
mongoose.connect(database);
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(express.static(__dirname + '/app/client'));
// Routers =====================================================================
var apiRouter = express.Router();
require('./app/server/routes/api')(apiRouter);
app.use('/api', apiRouter);
var authRouter = express.Router();
require('./app/server/routes/auth')(authRouter);
app.use('/auth', authRouter);
require('./app/server/routes')(app);
// listen (start app with node server.js) ======================================
module.exports = app.listen(port);
console.log("App listening on port " + port);