I have a controller called UsersController
with the following method:
module.exports = {
index: function(req, res, next){
Users.find({}, function(err, users){
if(err) return next(err);
if(!users) return next();
res.json({"data": users});
});
},
}
Which gives me a JSON
like this:
{
data: [
{
name: "Jhon Doe",
username: "jhon.doe",
email: "[email protected]",
role: 1,
logged: 0,
status: 1,
id: 1,
createdAt: "2016-10-28T00:42:04.000Z",
updatedAt: "2016-10-28T00:42:04.000Z"
}
]
}
And in my file config/routes.js
module.exports.routes = {
'GET /users/GET_ALL': {
controller: "UsersController",
action: "index"
}
}
If I access both routes /users/
and /users/GET_ALL/
I can get the JSON
shown above, my question is how can I get it (the JSON
) only through the path /users/GET_ALL/
and that when accessing the other /users/
send me a error 404
or whatever I want to show?