question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lambda functions can't be placed in sub directories

See original GitHub issue

This issue is a spin-off of #846

On Netlify, if you want to have the serverless function hello you can either have the file functions/hello.js or functions/hello/hello.js

Redwood currently only supports the first of those two options (functions/hello.js)

This issue is about adding support for the second way of doing it as well. Plus, possibly, functions/hello/index.js

All three options would result in a function available at http://localhost:8911/hello

Netlify’s docs for this are here https://docs.netlify.com/functions/build-with-javascript/

Potential steps brought over from the linked Issue

  • Determine how many levels on nesting is supported on netlify, vercel, etc. Netlify: Only one level. Vercel: Unlimited
  • Make the import code support nested subdirectories.
  • Make the various parts that reference the “name” work with subdirectories.
  • Write tests.

(Personally I don’t have a need for this right now, so anyone else; please feel free to pick this up if you want to)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
viperfxcommented, Jan 18, 2021

Would like to just add my use case here for this feature

With the redwood app I am working on, we integrate with different services. We are working on a Slack app, Intercom app, Zapier App etc.

We use the serverless functions to the do following functionality:

  • Oauth redirect and callback URLs
  • Incoming webhook support to integrate with platforms
  • APIs we create according to the platform spec.

So the project right now sits at close to 20 functions, and we are not yet done with the integrations we want to develop.

For code organization, I have used the following naming scheme, to make things a bit more manageable. [platform]-[function].js

e.g. intercom-oauth-callback.js, slack-auth.js

Another use case is the use of libraries such as https://quirrel.dev/ - which will greatly benefit from folder support. As each “queue” is a serverless function.

1reaction
Tobbecommented, Jul 22, 2020

Maybe not the best/fastest way as it added a layer, but it did make it organized and might be host-platform agnostic (works on Netlify and Vercel).

Having an Express app as a router on the top level (/feed in this case) is exactly what Netlify themselves use in their examples, so I think that’s a perfectly valid approach. To get that to work on Vercel I had to do some tricks with the vercel.json config files and the routing in there.

So if we choose this route (sorry 😛😁) we need to do this setup on Vercel as part of deployment.

next.js does some magic with their /pages/api folder. So it’s not impossible, just a bit of work 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to include a subdirectory of libraries in an AWS Lambda ...
With layers, you can use libraries in your function without needing to include them in your deployment package.
Read more >
Recursive patterns that cause run-away Lambda functions
Recursive patterns that cause run-away Lambda functions. AWS services generate events that invoke Lambda functions, and Lambda functions can send messages to ...
Read more >
Python Lambda handler in sub directory - Serverless Forums
I'm trying to define multiple Lambdas in one serverless.yml to be used in a Step Functions state machine.
Read more >
Does Netlify Lambda support sub-directory ? · Issue #90
Here's how I've added it so I can put my lambdas in a subdir - so I can use it with .netlify/function/net/lify ....
Read more >
Creating folders and subfolders in an S3 bucket using ...
... create folders and subfolders in an S3 bucket using Lambda Functions? ... in it you would put two objects to S3 with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found