Repository navigation
Expand file tree
/
Copy pathCommentController.js
More file actions
50 lines (47 loc) · 1.69 KB
/
Copy pathCommentController.js
File metadata and controls
50 lines (47 loc) · 1.69 KB
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
/**
* CommentController
*
* @module :: Controller
* @description :: A set of functions called `actions`.
*
* Actions contain code telling Sails how to respond to a certain type of request.
* (i.e. do stuff, then send some JSON, show an HTML page, or redirect to another URL)
*
* You can configure the blueprint URLs which trigger these actions (`config/controllers.js`)
* and/or override them with custom routes (`config/routes.js`)
*
* NOTE: The code you write here supports both HTTP and Socket.io automatically.
*
* @docs :: http://sailsjs.org/#!documentation/controllers
*/
"use strict";
module.exports = {
/**
* Overrides for the settings in `config/controllers.js`
* (specific to CommentController)
*/
_config: {},
/**
* Main history action. This will render object specified comment GUI where user
* can view, reply and add new comments.
*
* @param {Request} request Request object
* @param {Response} response Response object
*/
index: function(request, response) {
var objectId = request.param("objectId");
var objectName = request.param("objectName");
// Fetch specified object and id comments
DataService.getComments(objectName, objectId, 0, function(error, comments) {
if (error) {
ResponseService.makeError(error, request, response);
} else {
response.view({
objectId: objectId,
objectName: objectName,
comments: comments
});
}
});
}
};