nfp_sites/api/page/routes.mjs

27 lines
577 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/page/[path] */
async getPage(ctx) {
ctx.body = await this.Page.getPage(
ctx,
ctx.params.path || null,
ctx.query.get('page') || 1,
ctx.query.get('per_page') || 10
)
}
}