This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
generated from KennethTrecy/web_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(server): prepare router for tags
* mostly clones from `enhancer/role`
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
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 Validation from "!/bases/validation" | ||
import DepartmentManager from "%/managers/department" | ||
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 | ||
]) | ||
} | ||
|
||
get bodyParser(): null { return null } | ||
|
||
get validations(): Validation[] { return [] } | ||
|
||
getDocumentProps(): DocumentProps { | ||
return { | ||
"description": "List of tags available that can be attached to posts", | ||
"title": "Role list | Talakutnangan" | ||
} | ||
} | ||
|
||
async getPageProps(request: AuthenticatedRequest): Promise<Serializable> { | ||
const manager = new Manager(request) | ||
const departmentManager = new DepartmentManager(request) | ||
const pageProps = { | ||
"departments": await departmentManager.list({ | ||
"filter": { | ||
"existence": "exists", | ||
"slug": "" | ||
}, | ||
"page": { | ||
"limit": Infinity, | ||
"offset": 0 | ||
}, | ||
"sort": [ "fullName" ] | ||
}), | ||
"roles": await manager.list({ | ||
"filter": { | ||
"existence": "exists" | ||
}, | ||
"page": { | ||
"limit": 10, | ||
"offset": 0 | ||
}, | ||
"sort": [ "name" ] | ||
}) | ||
} | ||
|
||
return pageProps | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import GetList from "!%/enhancer/role/list.get" | ||
|
||
|
||
export const controllers = [ | ||
GetList | ||
] |