Commits to this repository should follow the conventional commits convention. Specially the angular convention.
Code in the master
branch is code ready to production, the dev
branch is a
buffer of code to be tested before it's ready to be merged into master
.
Production deploys need to create a release first. But the staging environment
can be used to test dev
code.
This project has a custom javascript linter. Make sure your code is passing
the project's linter. Before pushing new code. It can be done by using a linter
plugin in your text editor or by running the lint
script in package.json
.
To code, you should get a branch from the dev
(make sure it's updated with
the master
branch), and then make a pull request back into the dev
branch.
If possible request for a reviewer.
Hotfixes can be made directly into master
branch. But still need to generate
a new release before deploys.
To deploy a production image you should:
- make sure the changes are working
- merge
dev
intomaster
, or commit hotfixes inmaster
- update the version in
package.json
- update
CHANGELOG.md
with thechangelog
script - commit
CHANGELOG.md
andpackage.json
- create a tag
v<version>
, where<version>
is the new version - push changes into
master
, and also push the new tag - rebase
dev
withmaster
, and push it too - run
make deploy VERSION=<version>
You will need to install docker,
and you will also need an env file with environment variables called dev.env
.
This file should contain the following variables:
- PORT: the app will listen to this port
- DB_URL: the database connection url
- NODE_ENV: e.g.,
production
ordevelopment
- API_USER: user used for the api authentication, i.e., if the requester will be authorized to access this api. As of now this api has only one user
- API_PASSWORD: password for the user
Example dev.env
file:
NODE_ENV=development
DB_URL=mysql://bm:123@mysql/buy-messenger
PORT=7777
API_USER=unique-kangaroo-front
API_PASSWORD=244466666
Notice that if you are running a fresh install you may need to run the migrations. Check below to know how to do so.
I recommend using atom editor with the plugins
To make the initial setup run (this only needs to run once):
$ make bootstrap
After the bootstrap is done, you can always run the api with:
$ make run
It should build the apis's docker image, and run the mongo and the api services.
After docker-compose
finishes initializing the service the api will be
accessible in the localhost:<PORT>
address.
Any changes made locally will reflect in the docker container automatically.
If you are running a fresh install or if there have been changes to the database you will need to run the migrations to update the it.
$ docker exec apiprojectx_api_1 yarn run sequelize -- db:migrate
There are more functionalities in the makefile
, you can check it out.