redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.31k stars 995 forks source link

[RFC] Support routing on api functions #3213

Open dac09 opened 3 years ago

dac09 commented 3 years ago

Redwood's api functions don't really support routing - which is understandable as GraphQL is our primary endpoint to receieve/send data.

However there are certain cases that would benefit from supporting "routing" on the api side too

e.g. Receiving oauth callbacks

Here oauth is the actual function that takes parameters "github", "twitter" and "callback"

ℹ️ Note: This is possible using redirect settings on Netlify/Vercel/Render - but there isn't a built-in way to achieve this

Originally from @viperfx

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 quirrel.dev - which will greatly benefit from folder support. As each "queue" is a serverless function.

jtoar commented 2 years ago

Technically this will be possible after https://github.com/redwoodjs/redwood/pull/5903 lands.