RESTful Service
- You must be a member and added ssh key of workspace on bitbucket/gitlab. Clone the repo
git clone
- Framework ExpressJS v4.
- Validation API with Joi and fastest validator.
- Validate and generate default config environment.
- Authenticate JSON Web Token and auto refresh token in header.
- Handle permission user when calling API.
- Storage data on MongoDB.
- Data Source built with Apollo datasource and Dataloader.
- Caching result with Redis.
- Logging in winston.
- Documentation with Swagger.
- Compiler with Babel ES6.
- Auto create the first user (username: "admin", password: "123456)
This is an example of how to list things you need to use the software and how to install them.
-
NodeJS v14.4.x to up
-
MongoDB v4.x
-
Redis v5.x
Follow all step bellow to setup your dev environment
-
Setup as
Installing / Getting started
-
Start your environment (We are using Docker for environment setup)
-
Setup environment variables. Create environment config file and config
mongo
,rabbitmq
andredis
connection paramsGenerate secret token:
head -n 4096 /dev/urandom | openssl sha1
Paste the result into JWT_ACCESS_TOKEN_SECRET, JWT_REFRESH_TOKEN_SECRET in .env file
cp .env.example .env
- Install NPM packages
yarn install
- Run development:
yarn dev
You can start via docker compose
docker-compose up
Test your code before build.
$ yarn test:coverage
Run build command
$ yarn build
Push your code to your branch with format [__YOUR_USERNAME__]/[__FEATURE__]
$ git add .
$ git commit -m "__COMMIT_MESSAGE__"
$ git push origin [__YOUR_USERNAME__]/[__FEATURE__]
Then go to repository server and make a pull request to branch development
.
IMPORTANT: Don't push anything to master
by yourself. A CI tool will run all step and merge to master
for you.
- Install dependencies in production
yarn install --production=true
- Using swagger doc
- Document: http://localhost:9000/documentation
- Health Check: http://localhost:9000/health
On .env
, you must config all environment variables bellow. By default, .env.example
is used default config for all service.
The test library is Jest.
-
All test files must be located on
__tests__
and naming by format[name].spec.js
-
The folders/files on
__tests__
must be as same as onsrc
folder.
Just test
yarn test
Test a file
yarn test path/to/test/file
Test with coverage information
yarn test:coverage
-
[Current]
beta
: All code is onmaster
-
v1.0.0
Dev Team – @DEV – [email protected]