Create util-models.ts with some model utilities. Namely:
BaseAuthedModel is to be used by all the authenticated models to reduce boilerplate code.
roleCheck decorator to make it simpler to verify user permissions. Using this decorator requires us to enable experimentalDecorators in the tsconfig.
MethodParams utility type to easily extract arguments from class methods. Useful to minimize writing duplicate types when writing pass-through methods from an authed model to a non-authed model.
How you can test it
Deploy to staging, test that:
Query.users query works when authenticated
Query.users query throws error when not authenticated
What I'm changing
This PR converts the User model to TS
How I did it
.js
to.ts
util-models.ts
with some model utilities. Namely:BaseAuthedModel
is to be used by all the authenticated models to reduce boilerplate code.roleCheck
decorator to make it simpler to verify user permissions. Using this decorator requires us to enableexperimentalDecorators
in the tsconfig.MethodParams
utility type to easily extract arguments from class methods. Useful to minimize writing duplicate types when writing pass-through methods from an authed model to a non-authed model.How you can test it
Deploy to staging, test that:
Query.users
query works when authenticatedQuery.users
query throws error when not authenticatedPart of #187