-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (26 loc) · 999 Bytes
/
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
var express = require('express'),
Resource = require('express-resource'),
app = express(),
path = require('path'),
mongoose = require('mongoose'),
port = 8000,
projects, issues, comments
mongoose.connect('mongodb://localhost/myDB');
app.configure('development', function () {
app.set('title', 'My Application');
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, 'app'))); //TODO Change to 'public' in production!
app.use(function (err, req, res, next) {
// only handle `next(err)` calls
var errMessage = "-Caught exception on your call to " + req.route.path + ": " + err
console.log(errMessage)
res.send(500, errMessage)
});
})
projects = app.resource('projects', require('./resources/project'))
issues = app.resource('issues', require('./resources/issue'))
comments = app.resource('comments', require('./resources/comment'))
projects.add(issues)
issues.add(comments)
app.listen(port)
console.log("started node on port " + port)