Ghost/core/server/services/routing/PreviewRouter.js
Katharina Irrgang ff6bf5f318 Renamed /users to /authors for Content API V2 (#10096)
refs #10061

- Made /authors endpoint available in Content API V2
2018-11-07 15:29:37 +01:00

34 lines
777 B
JavaScript

const ParentRouter = require('./ParentRouter');
const urlService = require('../url');
const controllers = require('./controllers');
class PreviewRouter extends ParentRouter {
constructor() {
super('PreviewRouter');
this.route = {value: '/p/'};
this._registerRoutes();
}
_registerRoutes() {
this.router().use(this._prepareContext.bind(this));
this.mountRoute(urlService.utils.urlJoin(this.route.value, ':uuid', ':options?'), controllers.preview);
}
_prepareContext(req, res, next) {
res.routerOptions = {
type: 'entry',
query: {
alias: 'preview',
resource: 'posts'
}
};
next();
}
}
module.exports = PreviewRouter;