-
Notifications
You must be signed in to change notification settings - Fork 67
add support for background functions in api pages only #171
Conversation
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.
This looks great, @lindsaylevine! Very nice regex 😊
I agree with you that the risk of accidental background function seems rather minimal.
(One small caveat is that you can't have a background function with dynamic routing (e.g., api/[id]
or api/[...params]
). But I don't have a good idea/fix for this and I believe no one has asked for this, so seems totally OK for that to not be possible for the time being. Just wanted to flag that, because it crossed my mind.*)
*As a workaround, users can always create a dynamic API endpoint in addition to a non-dynamic background API endpoint and internally proxy from the former to the latter, converting path parameters into query parameters in the process (/:id
to ?id=:id
).
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.
This looks good to me.
Per the risk we could add a summary - created x routes, y functions, z background functions
or something similar (or event just print detect the following background functions
) to make it more visible.
Any ideas on when this might be published? Very useful and much needed feature! |
@sameeranand1 merging now, can release shortly ! |
NoN was just released, individually. note though, if you're using the plugin, this will not be released immediately with the updated NoN version, unless necessary/requested. |
Thanks! I’m using the node package - it’s in that release though, right? When you’re talking about the plug-in, you’re talking about through Netlify, right? Thanks! |
@sameeranand1 ah, yes, sorry for not being more specific! if you have |
Thanks @FinnWoelm! I look forward to contributing further to the project :) Thanks for applying the change from my PR @lindsaylevine -- I updated my fork to require the path to include I'll add a few more tests and submit another PR. Thanks again for adding the feature so quickly. |
@colinwirt absolutely! and yes, i shouldve noted the regex was/is 100% the work of colin! looking forward to seeing what you contribute next :) |
Fixes #166
want to get a range of eyes on this. there is a small risk mentioned in a comment inside regarding users possibly unknowingly creating background functions if theyre not familiar with them and happen to end their api page name in background. this was an ask by one specific user awhile ago and i think, as long as there's no real risk, this would be a great offering.
for now, i'm omitting an addition to the README documenting this support with a personal task to add it later. would like to run this by docs as well.