summaryrefslogtreecommitdiffstats
path: root/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/routes/user.js
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-08-07 11:39:39 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-08-07 11:39:39 +0800
commit21d72c4a80fe2937d0c4ddd20624b27adbcd989b (patch)
treee5013ee12f74f8452e01cbff16e7b0158bc456cb /common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/routes/user.js
parentf533e73e2ae32e010b16abdcf7985abaf31ab843 (diff)
Upload the ESR GUI seed code
Issue-ID: AAI-68 Change-Id: Ia50ce0570c2fabecd77199d4e8454f56fe587c4e Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/routes/user.js')
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/routes/user.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/routes/user.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/routes/user.js
new file mode 100644
index 0000000..f9ad33e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/examples/notes/routes/user.js
@@ -0,0 +1,22 @@
+var User = require('../models/user'),
+ Note = require('../models/note');
+
+// Here we can add custom route endpoints
+exports = module.exports = {
+ // an endpoint called notes
+ notes: {
+ handler: function(req, res, next, err, model) {
+ Note.Obj.find({ creator: model._id }, function(err, list) {
+ if (err) next({ status: 404 }); // Error handling
+ //res.status is the status code
+ res.status = 200;
+
+ // res.bundle is what is returned
+ res.bundle = list;
+ next();
+ });
+ },
+ detail: true, // detail makes sure we have one model to work on i.e. /user/:id/note is the uri
+ methods: ['get'], // only respond to GET requests
+ },
+}