kurierjs / kurier

TypeScript framework to create JSON:API compliant APIs
https://kurier.readthedocs.io/en/latest/
MIT License
61 stars 9 forks source link

Implements `jsonApiVercel` for Serverless Functions in Vercel #285

Closed joelalejandro closed 3 years ago

joelalejandro commented 3 years ago

Resolves #282.

Now that we've updated dependencies and released v1.1.0, we can move on with feature development. This PR introduces jsonApiVercel, a middleware for exposing a Kurier API as a serverless function.

joelalejandro commented 3 years ago

@spersico The only issue with this is that I'm not sure of a good way of testing it. I was thinking about a script that runs a dummy nextjs app and then another one that runs vercel dev to test the Vercel-only use case.

Thing is - we'd need to install both as devDependencies, and maybe it feels like too much.

spersico commented 3 years ago

@spersico The only issue with this is that I'm not sure of a good way of testing it. I was thinking about a script that runs a dummy nextjs app and then another one that runs vercel dev to test the Vercel-only use case.

Thing is - we'd need to install both as devDependencies, and maybe it feels like too much.

well.... as long as they are devDependencies, I don't think that it's THAT much. Maybe it could be set to run only on CI?

joelalejandro commented 3 years ago

I'll make changes in the docs to remove the mentiones to Next.js. That'll go in a separate middleware.

isBatak commented 3 years ago

I just want to share my experimentation with this API. Here is the repo https://github.com/isBatak/next-js-json-api-starter It's live here https://next-js-kurier-starter.vercel.app/ I used https://supabase.io/ free plan to get Postgres DB, it was a pretty straightforward solution.

joelalejandro commented 3 years ago

Excellent @isBatak! That covers basic functionality for plain entities without relationships. I discovered some issues with ?include= queries and I'm working on fixing those.

joelalejandro commented 3 years ago

@spersico The only issue with this is that I'm not sure of a good way of testing it. I was thinking about a script that runs a dummy nextjs app and then another one that runs vercel dev to test the Vercel-only use case. Thing is - we'd need to install both as devDependencies, and maybe it feels like too much.

well.... as long as they are devDependencies, I don't think that it's THAT much. Maybe it could be set to run only on CI?

Hmm, if we're putting them in devDependencies, I'd rather run the tests locally as well. Making this available just in CI feels like a DX friction.

joelalejandro commented 3 years ago

@isBatak Latest changes to jsonApiVercel are available for usage in kurier@1.2.0-alpha2, in case you want to try them out! In the meantime, this PR is getting merged 🚀