diff options
Diffstat (limited to 'common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/index.js')
-rw-r--r-- | common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/index.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/index.js new file mode 100644 index 00000000..6299c33a --- /dev/null +++ b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/index.js @@ -0,0 +1,25 @@ +var express = require('express'), + bodyParser = require('body-parser'), + methodOverride = require('method-override'), + mongoose = require('mongoose'), + morgan = require('morgan'), + restful = require('../'); +var app = module.exports = express(); + +// Connect to mongodb -- used to store the models +mongoose.connect("mongodb://localhost/expressmvc"); + +app.use(morgan('dev')); +app.use(bodyParser.urlencoded({'extended':'true'})); +app.use(bodyParser.json()); +app.use(bodyParser.json({type:'application/vnd.api+json'})); +app.use(methodOverride()); + +// expose a list of models to register +var models = require('./models/index'); +models.forEach(function(model) { + console.log("Register " + model.resourceName); + model.register(app, '/' + model.resourceName); +}); + +app.listen(3000); |