mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-04 04:10:33 +03:00
d81bc91bd2
refs #7116, refs #2001 - Changes the way Ghost errors are implemented to benefit from proper inheritance - Moves all error definitions into a single file - Changes the error constructor to take an options object, rather than needing the arguments to be passed in the correct order. - Provides a wrapper so that any errors that haven't already been converted to GhostErrors get converted before they are displayed. Summary of changes: * 🐛 set NODE_ENV in config handler * ✨ add GhostError implementation (core/server/errors.js) - register all errors in one file - inheritance from GhostError - option pattern * 🔥 remove all error files * ✨ wrap all errors into GhostError in case of HTTP * 🎨 adaptions - option pattern for errors - use GhostError when needed * 🎨 revert debug deletion and add TODO for error id's
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
var config = require('../../config'),
|
|
utils = require('../../utils'),
|
|
errors = require('../../errors'),
|
|
logging = require('../../logging'),
|
|
i18n = require('../../i18n'),
|
|
middleware = require('./lib/middleware'),
|
|
router = require('./lib/router'),
|
|
registerHelpers = require('./lib/helpers');
|
|
|
|
module.exports = {
|
|
activate: function activate(ghost) {
|
|
var paths;
|
|
|
|
if (utils.url.getSubdir()) {
|
|
paths = utils.url.getSubdir().split('/');
|
|
|
|
if (paths.pop() === config.get('routeKeywords').private) {
|
|
logging.error(new errors.GhostError({
|
|
message: i18n.t('errors.config.urlCannotContainPrivateSubdir.error'),
|
|
context: i18n.t('errors.config.urlCannotContainPrivateSubdir.description'),
|
|
help: i18n.t('errors.config.urlCannotContainPrivateSubdir.help')
|
|
}));
|
|
|
|
// @TODO: why
|
|
process.exit(0);
|
|
}
|
|
}
|
|
|
|
registerHelpers(ghost);
|
|
},
|
|
|
|
setupMiddleware: function setupMiddleware(blogApp) {
|
|
blogApp.use(middleware.checkIsPrivate);
|
|
blogApp.use(middleware.filterPrivateRoutes);
|
|
},
|
|
|
|
setupRoutes: function setupRoutes(blogRouter) {
|
|
blogRouter.use('/' + config.get('routeKeywords').private + '/', router);
|
|
}
|
|
};
|