Skip to content
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

chore: make event store accept IUser #3076

Merged
merged 3 commits into from Feb 21, 2023
Merged

Conversation

gastonfournier
Copy link
Contributor

@gastonfournier gastonfournier commented Feb 9, 2023

About the changes

Currently, we need to remember of using the email or else the username of a user when storing into EventStore, because we don't have strictNullChecks, it's error-prone. Fix for a production issue: #3072

I tried enabling strictNullChecks in our tsconfig file, but it reports 509 issues in 143 files.

This means we also need to check for undefined here:

this.createdBy =
typeof createdBy === 'string' || typeof createdBy === 'undefined'
? createdBy
: createdBy.email || createdBy.username || 'unknown';

@vercel
Copy link

vercel bot commented Feb 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated
unleash-docs ⬜️ Ignored (Inspect) Feb 21, 2023 at 2:05PM (UTC)
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Feb 21, 2023 at 2:05PM (UTC)

Comment on lines 145 to 146
typeof createdBy === 'string' || typeof createdBy === 'undefined'
? createdBy
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This maintains the same behaviour as before, if createdBy is passed as undefined we propagate that (which should break DB constraints and display an error)

Copy link
Contributor

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

:)

this.createdBy =
typeof createdBy === 'string'
? createdBy
: extractUsernameFromUser(createdBy);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gastonfournier gastonfournier enabled auto-merge (squash) February 21, 2023 14:09
@github-actions
Copy link

After enabling strictNullChecks this PR would be increasing the number of null check errors from 498 to 499. Make sure your branch is up-to-date with main and check the diff in the console output to gather more details

@gastonfournier gastonfournier merged commit dc0fe39 into main Feb 21, 2023
@gastonfournier gastonfournier deleted the event-store-interface-change branch February 21, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants