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

feat: return value from UseRequestContext callback #28

Merged
merged 1 commit into from
Aug 31, 2021

Conversation

TLmaK0
Copy link
Contributor

@TLmaK0 TLmaK0 commented Jul 9, 2021

Fixes: #21

@B4nan
Copy link
Member

B4nan commented Jul 9, 2021

thanks, can you please add some basic tests to verify it works and ensure we dont break it?

@TLmaK0
Copy link
Contributor Author

TLmaK0 commented Jul 10, 2021

Yes, of course, I will try next week

@TLmaK0 TLmaK0 changed the title UseRequestContext returns method return value UseRequestContext returns value from decorated method Jul 13, 2021
@TLmaK0 TLmaK0 force-pushed the master branch 2 times, most recently from e960f81 to e40ee8a Compare July 13, 2021 11:16
src/mikro-orm.common.ts Show resolved Hide resolved
tests/mikro-orm.common.spec.ts Outdated Show resolved Hide resolved
@@ -29,12 +29,12 @@ class ConfigService implements MikroOrmOptionsFactory {
@Module({ providers: [ConfigService, myLoggerProvider], exports: [ConfigService] })
class ConfigModule { }

const getEntityManagerLoop = async (module: TestingModule): Promise<Set<string>> => {
const getEntityManagerLoop = async (module: TestingModule): Promise<Set<number | string>> => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const getEntityManagerLoop = async (module: TestingModule): Promise<Set<number | string>> => {
const getEntityManagerLoop = async (module: TestingModule): Promise<Set<string>> => {

// this function mocks the contextId factory which is called on each request
// it's looped 5 times and resolves the EntityManager provider 10 times
// set only allows unique values, it should only return 5 items as it should resolve the same em with the same contextId

const generatedIds = new Set<string>();
const generatedIds = new Set<number | string>();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const generatedIds = new Set<number | string>();
const generatedIds = new Set<string>();

@B4nan
Copy link
Member

B4nan commented Aug 28, 2021

looks like i dont have write access to your fork, so please either rebase this and remove the conflicting changes in tests/mikro-orm.module.spec.ts

@B4nan B4nan changed the title UseRequestContext returns value from decorated method feat: return value from UseRequestContext callback Aug 31, 2021
@B4nan B4nan merged commit 4bf5b0f into mikro-orm:master Aug 31, 2021
@B4nan
Copy link
Member

B4nan commented Aug 31, 2021

thanks!

@TLmaK0
Copy link
Contributor Author

TLmaK0 commented Aug 31, 2021

My pleasure

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.

The UseRequestContext make the method return void
3 participants