Usages
-
Create a file starter.sh from filestarter.sh.sample.
-
DB migration
- Run the sql living in here
- Migration setting by typeorm for docker has not prepared.
Please help the settings...
- Migration setting by typeorm for docker has not prepared.
- Run the sql living in here
-
Run the following command.
$ docker-compose build
$ docker-compose run app /bin/bash
$ npm i
$ tsc
$ sh starter.sh
- Work on AWS Lambda with AWS API Gateway
- You need to prepare a stand alone database
- AWS CLI already configured with Administrator permission
- nodejs10.x installed
- Docker installed
- Typescript 3.7.x
template.yml
(Globals -> Function -> Environment -> Variables)- This is a setting for connect to a DB through the Lambda.
- ormconfig.json
- This is a setting for connect to a DB directly.
Initialize and Build local db on docker.
# build
make build-local-db
# migrate
make migrate-local-db
Start local db on docker.
docker-compose up -d
# generate migration file
ts-node $(npm bin)/typeorm migration:generate -n {name}
# run migration
ts-node $(npm bin)/typeorm migration:run
Migrate with AWS Cloud9.
// TODO : Wrting more how to migrate db.
-
Create files *.env.json from *.env.json.sample.
-
Run the following commands.
# select env
export ENV=(dev || stg || prod)
export STACK_NAME=coc-manager
# setting for env file
# Run 'brew install jq' if jq is not installed.
export ENV_PARAMS=$(jq -r '.Parameters | to_entries[] | "\(.key)=\"\(.value)\" \\"' env/$ENV.env.json)
# Build and test during development
make
# Build, Package and Deploy
make deploy-stack
make local-api
Individual lambda functions can be tested using the SAM CLI:
# Updates the handler.zip lambda package that SAM references
make local-package
sam local invoke <LAMBDA_FUNCTION_NAME>
- The
devDependencies
are installed in order fortsc
to compile the TypeScript code to Javascript - The dev
node_modules
are then removed and the production dependencies are installed and zipped in the lambda package