jetbridge / sst-prisma

Serverless Stack + Prisma ORM Template
MIT License
206 stars 21 forks source link

Question: Back vs Nextjs API #11

Closed khuezy closed 2 years ago

khuezy commented 2 years ago

Hi, thanks for creating this awesome starter kit!

Can you help me understand the difference between the backend/api and the /api that Nextjs creates (via the serverless-nextjs).

I would like to use prisma in the web/pages/api, how would I configure that?

How come there's a NAT for the RDS? The internal Lambdas should have access to RDS, right? I want to avoid setting up a NAT b/c their are rather expensive.

I would like to migrate/seed data to the database via a script though... I'd image the migrateScript you have is a good place to set that up during each deployment.

Thanks again!

revmischa commented 2 years ago

Can you help me understand the difference between the backend/api and the /api that Nextjs creates (via the serverless-nextjs).

I would like to use prisma in the web/pages/api, how would I configure that?

You can use either one - I use backend for providing my API - using AppSync or API gateway and lambda functions. You have full control over the design of it. You can use nextJS's web/pages/api and those will be in a separate environment running inside nextjs. I'm sure you can do a lot with it but it won't be using things like API Gateway or SQS or AppSync. It's your choice.

How come there's a NAT for the RDS? The internal Lambdas should have access to RDS, right? I want to avoid setting up a NAT b/c their are rather expensive.

It's required if you want your backend lambda functions to be able to talk to other hosts on the internet. If they aren't doing that then you can set nat gateways: 0.

I would like to migrate/seed data to the database via a script though... I'd image the migrateScript you have is a good place to set that up during each deployment.

Yeah I'm in the process of fixing that so it runs the migrations each deployment. I should have that working sometime this week.

Thanks again!

Very welcome!

I should enable Discussions