vikejs / bati

Next-gen scaffolder. Get started with fully-functional apps, and choose any tool you want.
https://batijs.dev
MIT License
258 stars 14 forks source link

feat: Hosting / AWS Lambda / Serverless Framework #338

Closed aheissenberger closed 2 months ago

aheissenberger commented 2 months ago

https://github.com/vikejs/bati/discussions/335

currently supports:

aheissenberger commented 2 months ago

@magne4000 Thank you for your Feedback - do you need more changes?

aheissenberger commented 2 months ago

I have a question related to the template functions $README.md.ts. I would like to use this to manipulate a yaml file but there is no reader for yaml and I am not allowed to import any other packages. I know I can embed the yaml in a string and manipulate the string, but I would prefer to read an existing yaml file, convert it to json and than export it again back to yaml.

magne4000 commented 2 months ago

I have a question related to the template functions $README.md.ts. I would like to use this to manipulate a yaml file but there is no reader for yaml and I am not allowed to import any other packages. I know I can embed the yaml in a string and manipulate the string, but I would prefer to read an existing yaml file, convert it to json and than export it again back to yaml.

I created a new loadYaml util. It's untested but fairly simple. If you need to update/fix it, it shouldn't be too difficult.

@magne4000 Thank you for your Feedback - do you need more changes?

I don't think so. I just need to try it out before merging :)

aheissenberger commented 2 months ago

How to run a specific pnpm test:e2e - I have added one and would like to only run this test e.g. FRAMEWORK+aws-lambda-serverless.spec.ts

phonzammi commented 2 months ago

@aheissenberger, pnpm run test:e2e --filter solid,express

aheissenberger commented 2 months ago

@magne4000 the problem with the e2e test failing sometimes but not allways is not related to this changes pnpm run test:e2e --keep --summarize --filter solid --steps build,test I had this error also on my macOS system.

magne4000 commented 2 months ago

Yes it sometimes happens due to some temp files being created, I usually just rerun the test manually.

magne4000 commented 2 months ago

@aheissenberger Please be sure to toggle this PR back to "Ready for review" once you consider I can review it again and test it.

aheissenberger commented 2 months ago

@aheissenberger Please be sure to toggle this PR back to "Ready for review" once you consider I can review it again and test it.

I have restarted with this:

  1. I have replaced the Serverless Framework with the AWS CDK - one of the reason is, that die new 4.x Version is no longer open source for companies with more than 2 Mio revenue
  2. will create an extra pull request for sentry react

How would you suggest to modle this requirement:

  1. there are multiple targets to deploy on AWS: AWS Lambda, Lambda@Edge which need different Wrappers for Hono,..
  2. there are multiple ways to create the requires infrastructure on AWS and deploy: AWS CDK, Serverless Framework, SST.dev, ...

My current idea is:

  1. a feature called aws-lambda which will add the wrapper to hono, hatip,..
  2. a feature called aws-cdk which provides a sample configuration to deploy to AWS
aheissenberger commented 2 months ago

With Universal Middleware directly supporting AWS Lambda there would be no need to add one of the serverless server frameworks like hono or hattip.

magne4000 commented 2 months ago

there are multiple targets to deploy on AWS: AWS Lambda, Lambda@Edge which need different Wrappers for Hono

If possible, we just edit hono-entry.ts. If that's too complex, let's just create other wrapper files like hono-entry-aws-edge.ts. I would suggest to choose just one at first, to limit the scope of the PR. That way I'll also be able to improve Bati's internal for future requirements

there are multiple ways to create the requires infrastructure on AWS and deploy: AWS CDK, Serverless Framework, SST.dev, ...

Same as above, choose one for now. This adds a lot of complexity to supports multiple of those I feel.

a feature called aws-lambda which will add the wrapper to hono, hatip,.. a feature called aws-cdk which provides a sample configuration to deploy to AWS

My goal is to have features with options soon for this kind of use cases. Usage would be: pnpm create bati --react --aws=lambda,cdk. I'll prioritize this. But for now, if we choose only CDK and Lamda, we can avoid creating another feature. Just put both in aws feature for now.

magne4000 commented 2 months ago

With Universal Middleware directly supporting AWS Lambda there would be no need to add one of the serverless server frameworks like hono or hattip.

It will not be straightforward to implement (in universal-middleware) and integrate (in bati), so you can assume that you will probably have finished this PR before I had time to properly support all this.