-
Notifications
You must be signed in to change notification settings - Fork 7
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(apply-context): Support MongoDB ObjectId as context variables #88
feat(apply-context): Support MongoDB ObjectId as context variables #88
Conversation
b4ce929
to
e92c138
Compare
src/utils/applyContext.ts
Outdated
@@ -36,7 +39,10 @@ export function applyContext<T extends object>( | |||
str.replace(reDelimiters, (_, path: string) => { | |||
const value = getValueFromPath(context, path); | |||
if (Array.isArray(value)) return `{${value}}`; | |||
if (value instanceof Object) return 'undefined'; | |||
if (value instanceof Object) { | |||
const json = value.toJSON?.(); |
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.
I'm seeing that the error is coming from this line because of the .
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.
Got it. Optional chaining is not supported in Node 13 and below. I will fix it.
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.
Thank you @Hybrid-Force, just for curiosity, how are you using this package?
# [4.17.0](v4.16.0...v4.17.0) (2022-08-18) ### Features * **apply-context:** support objects with toJSON method as context variables ([#88](#88)) ([ecb3dbc](ecb3dbc))
🎉 This PR is included in version 4.17.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thanks for this great lib! I am using it for API access control of a multi-tenant app that I am working on. |
Add MongoDB ObjectId support as context variables, and hopefully other types of objects with
toJSON
methods returning strings.