Closed BrandonKlotz closed 4 years ago
hey! thanks for opening this :). glad you found the custom netlify functions caveat/related issue. it's high on my list of priorities to support and will be included in the next major release. a potential workaround if you really needed it would be to build with the CLI, copy your custom function into out_functions and then deploy that.
netlify deploy --build
netlify deploy --prod
@lindsaylevine so I was trying to follow the steps you have to deploy from the CLI but also new to using Netlify CLI, so a lot of today I learned's but wasn't able to copy over the identity-signup into out_functions
(I tried also taking this folder out of my .gitignore
.
Thinking about this as a feature, it would be kind of interesting not change the file names in the same way we change api routes. I am imagining a list of all the function names that trigger by events and then in lib/helpers/setupNetlifyFunctionForPage.js
when we find a file that has one of these functions ['deploy-building', 'deploy-locked', 'identity-signup']
we just copy that over to the specified functions folder likely out_functions
I am trying to test this out locally and will post an update if I make any progress 😄
Made a work in progress/draft pull to work on this idea https://github.com/netlify/next-on-netlify/pull/60
side note the pre-commit tool that checks if you have run prettier is so rad, first time seeing something like that.
This may not be the most desirable way to implement this but it is definitely helping me understand some aspects of this package better.
setupNetlifyFunctionForPage
if a fileName is an event trigger functionUpdate after adding skip functionality for Netlify event trigger functions:
Update, ran netlify deploy --prod
and it seemed to work! But now I am trying to verify that when a user signs up that it fires this functions.
💠Think if this kind of feature is accepted or desired, I'm curious if it should be an option to these by passing a flag.
Something like:
next-on-netlify --withTriggerEvents
The good news, I think it is closer to working! 🎉
The other good news, I am about to learn how to write a working Netlify function, because that's definitely not working 🤣
Logs for the function
9:43:47 PM: 2020-10-17T01:43:47.931Z INFO [request] /.netlify/functions/identity-signup
9:43:47 PM: 2020-10-17T01:43:47.940Z ERROR TypeError: resolver is not a function
at apiResolver (/var/task/src/out_functions/identity-signup/nextJsPage.js:812:7)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Source: https://github.com/BrandonKlotz/netlify-identity-hooks
Update, maybe less close to a solution than I initially thought. Something I'm thinking about now is maybe we don't need to worry about coercing the fileName for Trigger events but just write custom redirects for them.
So I found out why I was running into some weirdness.
Steps to fixing:
yarn add micro@canary
9.3.5-canary.3
next-on-netlify
After signing up, the trigger event function properly ran!
hey @BrandonKlotz! thanks so much for working on this :). i'm going to be super distracted this week likely with other priorities but will try to check in on your progress/PR.
Sweet! As I understood better what I needed, #60 is a quick out-of-the-box way to support the Netlify Event Trigger Functions for those using next-on-netlify
.
The feature people have requested of custom function routes likely could also achieve the needs I have here, I could see that being the solution that eclipses this feature proposal. I had a lot of fun learning about this package through trying to make it support Trigger Functions.
Also was thinking another good issue I could probably add is write unit tests for the helpers/
folder. Think it would be a good way for me to contribute and learn more about each helper.
@BrandonKlotz sorry been swamped. i think you're right @ custom functions, which is Coming Soon TM. i'm glad you had fun working with next-on-netlify and trigger functions!!! :) we'd be lucky to have you contribute tests or contribute in general to the project!
Hi, I was wondering if there is a way to set functions as custom routes that will be picked up by Netlify's identity hooks.
The function that is produced in
next-on-netlify
:What I think Netlify Identity will trigger when someone signs up:
Looking at the docs: https://docs.netlify.com/functions/functions-and-identity/#trigger-serverless-functions-on-identity-events
I looked at the issue related to (https://github.com/netlify/next-on-netlify#custom-netlify-functions) but don't know that it is the same need here.
This is a weird question/issue I don't know if it is a feature request or a misunderstanding of how these two things interact. Happy to make this an example and add to docs when I better understand what's going on 😂