tnc-ca-geo / animl-api

Backend for https://animl.camera
4 stars 0 forks source link

TypeScript: Models(User) #207

Closed alukach closed 2 weeks ago

alukach commented 2 weeks ago

What I'm changing

This PR converts the User model to TS

How I did it

  1. Rename file from .js to .ts
  2. Create util-models.ts with some model utilities. Namely:
    1. BaseAuthedModel is to be used by all the authenticated models to reduce boilerplate code.
    2. roleCheck decorator to make it simpler to verify user permissions. Using this decorator requires us to enable experimentalDecorators in the tsconfig.
    3. 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:


Part of #187