A higher-order helper that wraps a controller function and automatically applies permission filtering on the result.
Example:
const getUser = withPermissions(User, async (id: number) => { return User.findByPk(id); });
const safeUser = await getUser(1, 'guest'); // safeUser has only the fields 'guest' is allowed to see
The model class whose permissions to apply
The async controller function (last arg must be role string)
A higher-order helper that wraps a controller function and automatically applies permission filtering on the result.
Example:
const getUser = withPermissions(User, async (id: number) => { return User.findByPk(id); });
const safeUser = await getUser(1, 'guest'); // safeUser has only the fields 'guest' is allowed to see