-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
pr05 Typescript Migration #13: Migrate the User Model (& API Key schema) #3672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
raclim
merged 24 commits into
processing:develop
from
clairep94:pr05/migrate_user_model_finalattempt
Oct 3, 2025
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
6d9fb34
eslint: turn off underscore-dangle warning
clairep94 dd4c6e6
install bcrypt type
clairep94 f10ae22
server/types: add email confirmation states & user preferences
clairep94 f56509f
package.json reorder after re-install
clairep94 2d37b08
server/models: refactor apiKey to its own file & add test
clairep94 0fc60bd
model/user: add unit test for user model
clairep94 ae11dc8
migrate to ts, no-verify
clairep94 17455f5
apiKey: first attempt at defining types --no-verify
clairep94 fc58c79
apiKey: add working types
clairep94 3baec8f
apiKey: migrate to separate types file
clairep94 6bb876f
turn on strict null checks for mongoose infer
clairep94 8c06deb
models/user: migrate to ts, no-verify
clairep94 2be814f
models/apiKey: re-implement in pattern from attempt 2 --no-verify
clairep94 bb61e13
model/user: test update to ts, no-verify
clairep94 3746446
model/user: update user mock and resolve failing tests, no-verify
clairep94 000963d
install sinon types, no-verify
clairep94 5f1efe8
models/user: update to named export, no-verify but tests pass
clairep94 790ba5b
models/user: resolve types using definitions from attempt 1 PR with t…
clairep94 0ebbf59
models/user: attach EmailConfirmationStates via function call
clairep94 9e121fd
cleanup
clairep94 2d71fc7
update user model test to use mongodb-memory-server for passing on lo…
clairep94 e453119
nominal change to trigger ci
clairep94 a713de7
Merge branch 'develop' into pr05/migrate_user_model_finalattempt
clairep94 23bb85a
merge with develop
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
models/user: resolve types using definitions from attempt 1 PR with t…
…ests passing
- Loading branch information
commit 790ba5b5fed38f63915214df8831836476fb02be
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,7 @@ describe('User model', () => { | |
|
|
||
| const found = await User.findByEmail('[email protected]'); | ||
| expect(found).not.toBeNull(); | ||
| expect(found.username).toBe('dave'); | ||
| expect(found!.username).toBe('dave'); // found exists otherwise the previous expect would fail | ||
| }); | ||
|
|
||
| it('should find user by username (case insensitive)', async () => { | ||
|
|
@@ -98,7 +98,7 @@ describe('User model', () => { | |
|
|
||
| const found = await User.findByUsername('eve', { caseInsensitive: true }); | ||
| expect(found).not.toBeNull(); | ||
| expect(found.email).toBe('[email protected]'); | ||
| expect(found!.email).toBe('[email protected]'); // found exists otherwise the previous expect would fail | ||
| }); | ||
|
|
||
| it('should return null for wrong username/email', async () => { | ||
|
|
@@ -115,7 +115,8 @@ describe('User model', () => { | |
| await user.save(); | ||
|
|
||
| const savedUser = await User.findOne({ email: '[email protected]' }); | ||
| const keyObj = await savedUser.findMatchingKey('hashedApiKey'); | ||
| expect(savedUser).not.toBeNull(); | ||
| const keyObj = await savedUser!.findMatchingKey('hashedApiKey'); // savedUser exists otherwise the previous expect would fail | ||
|
|
||
| expect(keyObj.isMatch).toBe(true); | ||
| expect(keyObj.keyDocument).not.toBeNull(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| export * from './apiKey'; | ||
| export * from './email'; | ||
| export * from './mongoose'; | ||
| export * from './user'; | ||
| export * from './userPreferences'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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,
usePushEachwas highlighting in red as it was deprecated for the current version of mongo, so I think we're meant to delete it