diff --git a/lib/history.js b/lib/history.js index c523c5ad..d4485591 100644 --- a/lib/history.js +++ b/lib/history.js @@ -9,14 +9,6 @@ var logger = require('./logger') var response = require('./response') var models = require('./models') -// public -var History = { - historyGet: historyGet, - historyPost: historyPost, - historyDelete: historyDelete, - updateHistory: updateHistory -} - function getHistory (userid, callback) { models.User.findOne({ where: { @@ -200,4 +192,8 @@ function historyDelete (req, res) { } } -module.exports = History +// public +exports.historyGet = historyGet +exports.historyPost = historyPost +exports.historyDelete = historyDelete +exports.updateHistory = updateHistory diff --git a/lib/response.js b/lib/response.js index 01fa0600..a2e92dc5 100644 --- a/lib/response.js +++ b/lib/response.js @@ -17,42 +17,40 @@ var utils = require('./utils') var history = require('./history') // public -var response = { - errorForbidden: function (res) { - const { req } = res - if (req.user) { - responseError(res, '403', 'Forbidden', 'oh no.') - } else { - req.flash('error', 'You are not allowed to access this page. Maybe try logging in?') - res.redirect(config.serverURL + '/') - } - }, - errorNotFound: function (res) { - responseError(res, '404', 'Not Found', 'oops.') - }, - errorBadRequest: function (res) { - responseError(res, '400', 'Bad Request', 'something not right.') - }, - errorTooLong: function (res) { - responseError(res, '413', 'Payload Too Large', 'Shorten your note!') - }, - errorInternalError: function (res) { - responseError(res, '500', 'Internal Error', 'wtf.') - }, - errorServiceUnavailable: function (res) { - res.status(503).send("I'm busy right now, try again later.") - }, - newNote: newNote, - showNote: showNote, - showPublishNote: showPublishNote, - showPublishSlide: showPublishSlide, - showIndex: showIndex, - noteActions: noteActions, - publishNoteActions: publishNoteActions, - publishSlideActions: publishSlideActions, - githubActions: githubActions, - gitlabActions: gitlabActions +exports.errorForbidden = function (res) { + const { req } = res + if (req.user) { + responseError(res, '403', 'Forbidden', 'oh no.') + } else { + req.flash('error', 'You are not allowed to access this page. Maybe try logging in?') + res.redirect(config.serverURL + '/') + } } +exports.errorNotFound = function (res) { + responseError(res, '404', 'Not Found', 'oops.') +} +exports.errorBadRequest = function (res) { + responseError(res, '400', 'Bad Request', 'something not right.') +} +exports.errorTooLong = function (res) { + responseError(res, '413', 'Payload Too Large', 'Shorten your note!') +} +exports.errorInternalError = function (res) { + responseError(res, '500', 'Internal Error', 'wtf.') +} +exports.errorServiceUnavailable = function (res) { + res.status(503).send("I'm busy right now, try again later.") +} +exports.newNote = newNote +exports.showNote = showNote +exports.showPublishNote = showPublishNote +exports.showPublishSlide = showPublishSlide +exports.showIndex = showIndex +exports.noteActions = noteActions +exports.publishNoteActions = publishNoteActions +exports.publishSlideActions = publishSlideActions +exports.githubActions = githubActions +exports.gitlabActions = gitlabActions function responseError (res, code, detail, msg) { res.status(code).render('error.ejs', { @@ -635,5 +633,3 @@ function renderPublishSlide (data, res) { }) res.render('slide.ejs', data) } - -module.exports = response