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

Commit

Permalink
intrn(route): add transaction in user archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Magtoto committed Nov 19, 2022
1 parent 3a0a78a commit bd2a389
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions routes/api/user/archive.delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FieldRules } from "!/types/validation"
import type { OptionalMiddleware } from "!/types/independent"
import { AuthenticatedIDRequest, Response } from "!/types/dependent"
import type { DeserializedUserProfile } from "$/types/documents/user"

Expand All @@ -9,6 +10,8 @@ import JSONController from "!/controllers/json"
import AuthorizationError from "$!/errors/authorization"
import NoContentResponseInfo from "!/response_infos/no_content"
import ActionAuditor from "!/middlewares/miscellaneous/action_auditor"
import TransactionCommitter from "!/middlewares/miscellaneous/transaction_committer"
import TransactionInitializer from "!/middlewares/miscellaneous/transaction_initializer"

import PermissionBasedPolicy from "!/policies/permission-based"
import { user as permissionGroup } from "$/permissions/permission_list"
Expand Down Expand Up @@ -45,6 +48,13 @@ export default class extends JSONController {
})
}

get postValidationMiddlewares(): OptionalMiddleware[] {
const initializer = new TransactionInitializer()
return [
initializer
]
}

makeBodyRuleGenerator(unusedRequest: AuthenticatedIDRequest): FieldRules {
return makeResourceIdentifierListDocumentRules("user", exists, UserManager)
}
Expand All @@ -61,9 +71,10 @@ export default class extends JSONController {
return new NoContentResponseInfo()
}

get postJobs(): ActionAuditor[] {
get postJobs(): OptionalMiddleware[] {
return [
new ActionAuditor("user.archive")
new ActionAuditor("user.archive"),
new TransactionCommitter()
]
}
}

0 comments on commit bd2a389

Please sign in to comment.