The imperative counterpart of a policy class: a plain function.
It receives the same dependencies a class would get through its constructor.
Decides whether the caller may proceed.
A factory producing a policy.
export const updatePostPolicy = definePolicy(({ posts }) => async (event) => { const post = await posts.find(event.get('id')) return post.authorId === event.getMetadataValue('auth')?.sub}) Copy
export const updatePostPolicy = definePolicy(({ posts }) => async (event) => { const post = await posts.find(event.get('id')) return post.authorId === event.getMetadataValue('auth')?.sub})
The imperative counterpart of a policy class: a plain function.
It receives the same dependencies a class would get through its constructor.