2022-04-19 17:42:07 +00:00
|
|
|
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)
|
|
|
|
}
|
2022-06-28 08:15:51 +00:00
|
|
|
|
2022-07-20 00:33:06 +00:00
|
|
|
/** GET: /api/pages/[path] */
|
2022-06-28 08:15:51 +00:00
|
|
|
async getPage(ctx) {
|
|
|
|
ctx.body = await this.Page.getPage(
|
|
|
|
ctx,
|
|
|
|
ctx.params.path || null,
|
2022-07-20 00:33:06 +00:00
|
|
|
Math.max(ctx.query.get('page') || 1, 1),
|
|
|
|
Math.min(ctx.query.get('per_page') || 10, 25)
|
2022-06-28 08:15:51 +00:00
|
|
|
)
|
|
|
|
}
|
2022-04-19 17:42:07 +00:00
|
|
|
}
|