Kitstarter for API using Docker, Typescript and Hapi.js and good practices.
This project works with docker.
- Download this repo
- Launch :
npm install
- Install typescript globally for compilation:
npm install -g typescript
- Put .env file (project root)
Example:
NODE_ENV=development
PORT=5000
HOST=kitstarter-api.local
ALLOWED_CORS=http://localhost,http://kitstarter-api.local:5000
CACHE_EXPIRES_IN=1800000
MYSQL_ROOT_USER=root
MYSQL_ROOT_PASSWORD=admin
MYSQL_SHOP_HOST=database
MYSQL_SHOP_PORT=3306
MYSQL_SHOP_USER=root
MYSQL_SHOP_PASSWORD=admin
MYSQL_SHOP_DATABASE=kitstarter
ADM_HOST=database
ADM_PORT=3306
TYPEORM_SHOP_NAME=''
For dev environnement, you can build the env with make build-dev
then run with make dev
For production environnement, you can build the env with make build-prod
then run with make prod
Go on: kitstarter-api.local:5000/api/v1/hello
If you need to use Joi for response validation (in other words, if you create a new schema in /src/schema), you shouldn't create corresponding interfaces manually. You have to run :
npm run types
This will create automatically your interfaces. Joi is used to build route documentation and to validate route params, query, response, etc.
This project use Chai and Mocha for units tests
Run tests :
make tests
kitstarter-api.local:5000/api/v1/documentation