Skip to content

Conversation

clairep94
Copy link
Collaborator

@clairep94 clairep94 commented Sep 27, 2025

Migration of the user model to ts

  • made some assumptions/work arounds to solve type errors
  • This is a best effor, I will attempt the user controller next -- I expect that that attempt may result in tweaks to this file afterwards
    • I actually originally attempted to migrate the entire user system (controller, model, routes) but this was too difficult to do without previous PRs being finalised and merged. Please see here for that attempt
  • Added a test for the user model before migrating, so I could ensure nothing breaks
  • All tests pass & all typechecks pass

Changes:

  • Move apikey schema to its own file
  • Add test for user model
  • Extract types from user and api key
    • Note: my original approach was to use mongoose inferSchemaType and other infers but this was honestly really hard to debug and it was easier to explicity define what we expect from the types and feed it to the mongoose scheme definition, and attach the extra Document methods
  • Migrate apiKey and user to ts & to named export

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123
  • meets the standards outlined in the accessibility guidelines

@clairep94 clairep94 marked this pull request as ready for review September 27, 2025 13:31
@clairep94 clairep94 changed the title Pr05/migrate user pr05 Typescript Migration #13: Migrate the User Model (& API Key schema) Sep 27, 2025
lastLoginTimestamp: { type: Date }
},
{ timestamps: true, usePushEach: true }
{ timestamps: true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need usePushEach anymore? is it set to that by default? just wanted to make sure it didn't slip through the cracks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants