-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (31 loc) · 4.06 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
"use strict";
var express = require("express");
var errorHandler = require("errorhandler");
var methodOverride = require("method-override");
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var routes = require("./server-src/routes/index");
var api = require("./server-src/routes/api");
var app = express();
// Configuration
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(express.static(__dirname + '/frontend'));
var env = process.env.NODE_ENV || 'development';
if (env === 'development') {
app.use(errorHandler());
}
var dbName = 'userDB';
mongoose.connect('mongodb://localhost/' + dbName);
// Routes
api.initRoutes(app);
app.get('/', routes.index);
app.get('/*', function (req, res) {
res.redirect('/');
});
app.listen(3000, function () {
console.log("Demo Express server listening on port %d in %s mode", 3000, app.settings.env);
});
exports.App = app;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsSUFBWSxPQUFPLFdBQU0sU0FBUyxDQUFDLENBQUE7QUFDbkMsSUFBWSxZQUFZLFdBQU0sY0FBYyxDQUFDLENBQUE7QUFDN0MsSUFBWSxjQUFjLFdBQU0saUJBQWlCLENBQUMsQ0FBQTtBQUNsRCxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsYUFBYSxDQUFDLENBQUM7QUFDeEMsSUFBWSxRQUFRLFdBQU0sVUFBVSxDQUFDLENBQUE7QUFDckMsSUFBWSxNQUFNLFdBQU0sMkJBQTJCLENBQUMsQ0FBQTtBQUNwRCxJQUFZLEdBQUcsV0FBTSx5QkFBeUIsQ0FBQyxDQUFBO0FBRS9DLElBQUksR0FBRyxHQUFHLE9BQU8sRUFBRSxDQUFDO0FBRXBCLGdCQUFnQjtBQUNoQixHQUFH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