Ghost/core/frontend/apps/private-blogging/lib/router.js
Hannah Wolfe 22e13acd65 Updated var declarations to const/let and no lists
- All var declarations are now const or let as per ES6
- All comma-separated lists / chained declarations are now one declaration per line
- This is for clarity/readability but also made running the var-to-const/let switch smoother
- ESLint rules updated to match

How this was done:

- npm install -g jscodeshift
- git clone https://github.com/cpojer/js-codemod.git
- git clone git@github.com:TryGhost/Ghost.git shallow-ghost
- cd shallow-ghost
- jscodeshift -t ../js-codemod/transforms/unchain-variables.js . -v=2
- jscodeshift -t ../js-codemod/transforms/no-vars.js . -v=2
- yarn
- yarn test
- yarn lint / fix various lint errors (almost all indent) by opening files and saving in vscode
- grunt test-regression
- sorted!
2020-04-29 16:51:13 +01:00

46 lines
1.1 KiB
JavaScript

const path = require('path');
const express = require('express');
const middleware = require('./middleware');
const bodyParser = require('body-parser');
const routing = require('../../../services/routing');
const web = require('../../../../server/web');
const templateName = 'private';
const privateRouter = express.Router();
function _renderer(req, res) {
res.routerOptions = {
type: 'custom',
templates: templateName,
defaultTemplate: path.resolve(__dirname, 'views', `${templateName}.hbs`)
};
// Renderer begin
// Format data
let data = {};
if (res.error) {
data.error = res.error;
}
// Render Call
return routing.helpers.renderer(req, res, data);
}
// password-protected frontend route
privateRouter
.route('/')
.get(
middleware.isPrivateSessionAuth,
_renderer
)
.post(
bodyParser.urlencoded({extended: true}),
middleware.isPrivateSessionAuth,
web.shared.middlewares.brute.privateBlog,
middleware.authenticateProtection,
_renderer
);
module.exports = privateRouter;
module.exports.renderer = _renderer;