Skip to content

Commit

Permalink
docs: update lambda-function-url with examples of fronting with Cloud…
Browse files Browse the repository at this point in the history
…Front including loadtests
  • Loading branch information
brettstack committed Apr 14, 2024
1 parent c081dfe commit 115889f
Show file tree
Hide file tree
Showing 28 changed files with 6,556 additions and 562 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
npm-debug.log
.DS_Store
.env
!examples/lambda-function-url/**/*.env
coverage
sam-template.packaged.yaml
codegenie-serverless-express-*.tgz
Expand Down
2 changes: 1 addition & 1 deletion examples/lambda-function-url/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = {
'no-console': [
'warn',
{
allow: ['info', 'warn', 'error'],
allow: ['info', 'warn', 'error', 'time', 'timeEnd'],
},
],
'react/no-unknown-property': [
Expand Down
4 changes: 4 additions & 0 deletions examples/lambda-function-url/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
experimentalTernaries: true
semi: false
singleQuote: true
printWidth: 140
39 changes: 34 additions & 5 deletions examples/lambda-function-url/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
## Project Generated by Code Genie

This project was initially generated using [Code Genie](https://codegenie.codes) via the following command:

```sh
npx @codegenie/cli generate \
--name "Todo" \
--description "A todo list app that lets users create lists and add items to the list. Items should have a title, description, be markable as completed, have a due date, and have an image." --deploy
```

## Pre-requisites

* [AWS Account + CLI](https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html)
* Node.js
- [AWS Account + CLI](https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html)
- Node.js

## Running UI locally

```
npm i
npm run start:dev # or npm run start:prod
```

To change what the UI uses as its API endpoint, open `packages/ui/.env.[development|production]` and change `NEXT_PUBLIC_ApiEndpoint` to be one of the values of `NEXT_PUBLIC_ApiGatewayUrl`, `NEXT_PUBLIC_LambdaFunctionUrl`, or `NEXT_PUBLIC_CloudFrontDistributionUrl` and re-run `npm run start:dev|prod`

Note that both dev and prod are nearly identical except dev has sourcemaps enabled.

## Running loadtests

3 separate load testing tools are being experimented with. Run with one of:

```
npm run [loadtest | loadtest:autocannon | loadtest:artillery]
```

## Getting started

Run `npm run init:dev` to deploy a developer instance to your AWS account. This command does the following:

1. Installs NPM dependencies (`npm i`)
1. Creates a new entry in `~/.aws/credentials` called `todo_development` using credentials copied from the `default` profile.
* If you'd rather copy credentials from a different profile, run `COPY_AWS_PROFILE=profile-name-to-copy npm run init:dev`, or if you'd rather not copy any credentials, run `COPY_AWS_PROFILE=0 npm run init:dev` (this requires you to manually define a profile named `todo_development`).
- If you'd rather copy credentials from a different profile, run `COPY_AWS_PROFILE=profile-name-to-copy npm run init:dev`, or if you'd rather not copy any credentials, run `COPY_AWS_PROFILE=0 npm run init:dev` (this requires you to manually define a profile named `todo_development`).
1. Bootstraps CDK in the AWS account (`npm run cdk-bootstrap:dev`)
1. Deploys to AWS (`npm run deploy:dev`)
* Since the UI has a dependency on Cognito and the API, this setup command actually runs deploy a second time.
- Since the UI has a dependency on Cognito and the API, this setup command actually runs deploy a second time.
1. Copies CloudFormation/CDK outputs to local `.env` files for running the UI and API locally.
1. Opens the live version of the web app.

Expand All @@ -38,4 +67,4 @@ Note that this will still use your other cloud resources (e.g. Database and Auth

## Pull outputs

Note that sometimes when you receive a CDK/CloudFormation error (e.g. after a CloudFormation rollback), the `cdk-outputs.json` file gets wiped and you need to re-run `npm run pull-stack-outputs:dev`.
Note that sometimes when you receive a CDK/CloudFormation error (e.g. after a CloudFormation rollback), the `cdk-outputs.json` file gets wiped and you need to re-run `npm run pull-stack-outputs:dev`.
Loading

0 comments on commit 115889f

Please sign in to comment.