Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(route): tag list enhancer
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Magtoto committed Nov 14, 2022
1 parent cb423dd commit 3fb6ed9
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions routes/enhancer/tag/list.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type { Serializable } from "$/types/general"
import type { DocumentProps } from "$/types/server"
import type { AuthenticatedRequest } from "!/types/dependent"

import Policy from "!/bases/policy"
import Manager from "%/managers/tag"
import PageMiddleware from "!/bases/controller-likes/page_middleware"

import PermissionBasedPolicy from "!/policies/permission-based"
import { tag as permissionGroup } from "$/permissions/permission_list"
import { CREATE, UPDATE, ARCHIVE_AND_RESTORE } from "$/permissions/tag_combinations"

export default class extends PageMiddleware {
get filePath(): string { return __filename }

get policy(): Policy {
return new PermissionBasedPolicy(permissionGroup, [
CREATE,
UPDATE,
ARCHIVE_AND_RESTORE
])
}

getDocumentProps(): DocumentProps {
return {
"description": "List of tags in Talakutnangan",
"title": "Tag list | Talakutnangan"
}
}

async getPageProps(request: AuthenticatedRequest): Promise<Serializable> {
const manager = new Manager(request)

const pageProps = {
"tags": await manager.list({
"filter": {
"existence": "exists",
"slug": ""
},
"page": {
"limit": 10,
"offset": 0
},
"sort": [ "name" ]
})
}

return pageProps
}
}

0 comments on commit 3fb6ed9

Please sign in to comment.