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.
- Loading branch information
Angelo Magtoto
committed
Nov 14, 2022
1 parent
fb5109f
commit cb423dd
Showing
1 changed file
with
56 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,56 @@ | ||
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 present from "!/validators/manager/present" | ||
import IDParameterValidator from "!/validations/id_parameter" | ||
import PageMiddleware from "!/bases/controller-likes/page_middleware" | ||
|
||
import { UPDATE } from "$/permissions/tag_combinations" | ||
import PermissionBasedPolicy from "!/policies/permission-based" | ||
import { tag as permissionGroup } from "$/permissions/permission_list" | ||
|
||
export default class extends PageMiddleware { | ||
get filePath(): string { return __filename } | ||
|
||
get policy(): Policy { | ||
return new PermissionBasedPolicy(permissionGroup, [ | ||
UPDATE | ||
]) | ||
} | ||
|
||
get validations(): Validation[] { | ||
return [ | ||
new IDParameterValidator([ | ||
[ "id", Manager, present ] | ||
]) | ||
] | ||
} | ||
|
||
getDocumentProps(): DocumentProps { | ||
return { | ||
"description": "Consultation chat platform for MCC", | ||
"title": "Edit Tag | Talakutnangan" | ||
} | ||
} | ||
|
||
async getPageProps(request: AuthenticatedRequest): Promise<Serializable> { | ||
const { id } = request.params | ||
const manager = new Manager(request) | ||
|
||
const tag = await manager.findWithID(Number(id), { | ||
"constraints": { | ||
"filter": { | ||
"existence": "*" | ||
} | ||
} | ||
}) | ||
|
||
return { | ||
tag | ||
} | ||
} | ||
} |