initial commit

This commit is contained in:
Blue 2018-08-05 00:46:25 +03:00 committed by Юрий Губич
commit 4b60ece582
327 changed files with 28286 additions and 0 deletions

View file

@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
configure_file(errorHandler.js errorHandler.js)
configure_file(reply.js reply.js)
configure_file(notFound.js notFound.js)
configure_file(pageInMagnus.js pageInMagnus.js)

View file

@ -0,0 +1,36 @@
var defaultHandler = require("errorhandler");
var config = require("../config");
var log = require("../lib/log");
var HttpError = require("../lib/httpError");
function errorHandler(err, req, res, next) {
if (typeof err == "number") {
err = new HttpError(err);
}
if (err instanceof HttpError) {
sendHttpError(err, res, req);
} else {
if (config.get("build") === "debug") {
var handler = defaultHandler();
handler(err, req, res, next);
} else {
log.error(err);
err = new HttpError(500);
sendHttpError(err, res, req);
}
}
}
function sendHttpError(error, res, req) {
res.status(error.status);
//if (req.headers['x-requested-with'] == 'XMLHttpRequest') {
// res.json(error);
//} else {
// res.reply(error);
//}
res.reply(error);
}
module.exports = errorHandler;

View file

@ -0,0 +1,6 @@
"use strict";
var HttpError = require("../lib/httpError");
module.exports = function(req, res, next) {
return next(new HttpError(404, 'Page not found!'));
};

View file

@ -0,0 +1,9 @@
"use strict";
module.exports = function(req, res, next) {
if (global.magnus.hasPage(req.path)) {
res.reply("Building " + req.path + "...");
} else {
next();
}
};

View file

@ -0,0 +1,8 @@
"use strict";
var path = require("path");
module.exports = function(req, res, next) {
res.reply = function(info) {
this.render("index", {info: info});
};
next();
};