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

Optional tenant id checking based on request route path #30

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ephrimlawrence
Copy link
Contributor

@ephrimlawrence ephrimlawrence commented Jul 7, 2022

Fix for #27

This PR adds skipTenantCheck option to TenancyModuleOptions. If skipTenantCheck is true for a request, tenant database connection will be bypassed.

As in the example below, the tenant DB connection will be bypassed for all /birds* routes.

TenancyModule.forRoot({
   tenantIdentifier: 'X-TenantId',
   options: {},
   uri: (tenantId: string) => `mongodb://localhost/tenant-${tenantId}`,
   skipTenantCheck: (req) => req.route.path.match(/^\/birds*/) != null,
})

@ephrimlawrence ephrimlawrence changed the title Optional tenant id checking Optional tenant id checking based on request route path Aug 23, 2022
@ephrimlawrence
Copy link
Contributor Author

@sandeepsuvit any feedback on this PR? We really need the optional tenancy check feature

@sandeepsuvit
Copy link
Contributor

Hi @ephrimlawrence the reason why i kept it on hold is because of difference of opinions on this implementation. Please refer to the following comment

Also there is another PR pending with similar functionality but using a guard implementation.

Please let me know your viewpoint on these.

@Robokishan
Copy link

This is very good feature.! any thing you can do this to merge ?
@sandeepsuvit

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.

3 participants