Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

tktcorporation/coc-manager

Repository files navigation

Overview

FOSSA Status

Usages

Docker

Requirements

Usage

  1. Create a file starter.sh from filestarter.sh.sample.

  2. DB migration

    • Run the sql living in here
      • Migration setting by typeorm for docker has not prepared.
        Please help the settings...
  3. Run the following command.

$ docker-compose build
$ docker-compose run app /bin/bash

$ npm i
$ tsc
$ sh starter.sh

AWS SAM

  • Work on AWS Lambda with AWS API Gateway
  • You need to prepare a stand alone database

Requirements

Database settings

db config

  • 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

db migration

local
# generate migration file
ts-node $(npm bin)/typeorm migration:generate -n {name}

# run migration
ts-node $(npm bin)/typeorm migration:run
dev stg prod

Migrate with AWS Cloud9.
// TODO : Wrting more how to migrate db.

Packaging and deployment

  1. Create files *.env.json from *.env.json.sample.

  2. 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

Local test

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>
Packaging notes
  • The devDependencies are installed in order for tsc 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

License

FOSSA Status