xsh-node-business-info-provider
v0.0.10
Published
middleware library for business info
Downloads
2
Readme
signing-entity-middleware
Ownership
Team: Your team
Slack Channel: #team-channel
Slack Mentions: @team-mention
Conventions
File Name
We prefer hyphens (kebab-case) this-file-name vs underscores (snake_case) this_file_name
Development
Prerequisite
- VSCode
- Installed Docker
- Node LTS
- docker-compose newer than version 1.17.3
Start development environment
- Create
.env
file or runcp .env.example .env
- Create
.npmrc
file or runcp .npmrc.example .npmrc
You can look for the example in the .env.example
and .npmrc.example
. Paste the actual token in newly created .npmrc
file.
.npmrc.example
will be where you would put non sensitive npm configs that you would like to be shared across your team.
Next up you can choose to run your development environment entirely inside Docker or to run the app server directly on your local machine.
Running app server inside Docker
- Start the development cluster
docker-compose up -d
- View consolidated logs via Docker Compose
docker-compose logs -f
- Log into app container
# the command below will open a shell session inside our app container
docker exec -it signing-entity-middleware sh
# this is for executing CLI in dev env, for i.e. DB migration command like below
npm run migration:run
- Shutdown development cluster
docker-compose down
Running app server directly on your local machine's environment
- Start the db service in Docker
docker-compose up -d postgres
- Start your app server
npm run start:dev
# you might also want to migrate the DB with this command below
npm run migration:run
- Shutdown development cluster
docker-compose down
Testing
Prerequisite
- Installed Docker
- Node LTS
Run the test
Tests are split into two types
- unit: which does not requires db instance
- integration: which requires db instance
In order to run both unit and integration test use: npm run test:all
In order to run unit test only use: npm run test
In order to run integration tests
, you need to have a local postgresql running for your test environment:
# dockest runs a test postgres container for your tests and run migrations for you before starting the test
# dockest will also spin the container down automatically and all data will be wiped clean
npm run test-integration:dockest
If you want to do TDD, run the test in watch mode or simply running the test without dockest, you can spin up the test postgres containers
# Start the test postgres container
docker-compose -f docker-compose.test.yml up -d
# Update the .env file to point to ports 54320 for the test postgres container
npm run migration:run
# Run the test
npm run test
Database migration
Before continuing, please learn about the fundamentals of migration with TypeORM here
On first time setting up the DB
Run migration
npm run migration:run
If you made new changes to the db
Modifying columns in entities, or adding new entities (migration file is a class, start with CapitalLetter) Please refer to 1571751456489-Init.ts for changes to be made to the migration file to satisfy linting rules
It's a good idea to generate a new migration for every atomic changes made to the db
Generate migration
npm run migration:generate -- -n <migration-name> # eg. add-disbursement-column
If you made a mistake on running migration
Revert will revert migration file by file
Revert migration
npm run migration:revert
If you need a manual migration
For eg you need to add new extensions or simply custom migration
Create migration
npm run migration:create -- -n <MigrationName>
Deployment
Go to https://buddy.tidnex.com/xendit-inc/create-project to create a new project. Click on the repository that you want to import to BuddyWorks.
After you import the repository to BuddyWorks, every commit and PR that you make will trigger a CI (Continuous Integration) Test that will appear on your PR.
To deploy to
staging
, create a tag release with the version<VERSION>rc
, for examplev1.0.0-rc
.To deploy to
production
, create a tag release with the version like<VERSION>
, for examplev1.0.0
.
For more information on the flow for deploying through Github, check out the Github Flow RFC or RFC 13 - Trident