Sails app

This commit is contained in:
Ben Ramey
2014-03-08 18:32:43 -06:00
parent fb64ad1f45
commit 2a34de5580
44 changed files with 5802 additions and 0 deletions

38
config/404.js Normal file
View File

@@ -0,0 +1,38 @@
/**
* Default 404 (Not Found) handler
*
* If no route matches are found for a request, Sails will respond using this handler.
*
* This middleware can also be invoked manually from a controller or policy:
* Usage: res.notFound()
*/
module.exports[404] = function pageNotFound(req, res) {
/*
* NOTE: This function is Sails middleware-- that means that not only do `req` and `res`
* work just like their Express equivalents to handle HTTP requests, they also simulate
* the same interface for receiving socket messages.
*/
var viewFilePath = '404';
var statusCode = 404;
var result = {
status: statusCode
};
// If the user-agent wants a JSON response, send json
if (req.wantsJSON) {
return res.json(result, result.status);
}
res.status(result.status);
res.render(viewFilePath, function (err) {
// If the view doesn't exist, or an error occured, send json
if (err) { return res.json(result, result.status); }
// Otherwise, serve the `views/404.*` page
res.render(viewFilePath);
});
};