nfp_sites/api/page/routes.mjs

27 lines
605 B
JavaScript

import * as Page from './model.mjs'
import * as security from './security.mjs'
export default class PageRoutes {
constructor(opts = {}) {
Object.assign(this, {
Page: opts.Page || Page,
security: opts.security || security,
})
}
/** GET: /api/pagetree */
async getPageTree(ctx) {
ctx.body = await this.Page.getTree(ctx)
}
/** GET: /api/pages/[path] */
async getPage(ctx) {
ctx.body = await this.Page.getPage(
ctx,
ctx.params.path || null,
Math.max(ctx.query.get('page') || 1, 1),
Math.min(ctx.query.get('per_page') || 10, 25)
)
}
}