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
khanniie
khanniie previously approved these changes 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!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for catching this! It was used for older mongo versions, and is no longer needed past v5, so i think we might be good here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi guys sorry for the delayed response! Yess once I migrated this file to ts, usePushEach was highlighting in red as it was deprecated for the current version of mongo, so I think we're meant to delete it

@clairep94 clairep94 added the pr05 Grant Projects pr05 Grant Projects label Oct 2, 2025
Copy link
Collaborator

@raclim raclim left a comment

Choose a reason for hiding this comment

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

Merging this in!

@raclim raclim merged commit 0ccfd0e into processing:develop Oct 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr05 Grant Projects pr05 Grant Projects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants