- Compression Using gzip compression with Compression
- CORS Cross-Origin Resource-Sharing enabled using Cors
- Environment Variable using dotenv
- Secure HTTP Headers using Helmet
- Node.js JavaScript run-time environment
- Express Node.js framework
- Typescript for type checking
- Jest, ts-jest for unit testing
- Supertest for e2e testing
- ESLint for code linting
- Prettier for code formatting
- MongoDB Database
PAPI-STARTER
├── build
├── coverage
├── node_modules
├── src
│ ├── assets
│ ├── config
│ ├── database
│ ├── middleware
│ ├── modules
│ │ └── example
│ │ ├── controller
│ │ ├── model
│ │ ├── use-case
│ │ ├── validation
│ │ └── router.ts
│ ├── services
│ └── test
│ ├── setup.ts
│ ├── teardown.ts
│ └── utils.ts
├── .env
├── .env.example
├── .env.text
├── .env.test.example
└── README.md
Since transactions are built on concepts of logical sessions they require mechanics which are only available in a replica set environment.
Choose one of the options that you prefer
-
Install offline MongoDB database replica set using docker Docker MongoDB RS
-
Use online Database as a Service (DBaaS) Atlas MongoDB
If you are using docker for installation, currently we cannot connect it to the local MongoDB database. So you should use an online database for development
You still need to install dependencies locally to enable development features like eslint, prettier, and test.
cp .env.example .env
cp .env.test.example .env.test
npm install
docker-compose up
cp .env.example .env
cp .env.test.example .env.test
npm install
npm run dev
node cli db:init
node cli db:seed
Setup Database Schema
node cli db:init --db-name="starterTestDB"
Testing all test case
npm run test
Testing specific file or folder
# Test specific file
npm run test -- src/modules/example/controller/create.spec
# Test specific folder
npm run test -- src/modules/example/controller
# Test example module
npm run test -- src/modules/example
(Optional) Running test from docker
- Check running container
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
902293b368b3 papi-starter-api "docker-entrypoint.s…" About an hour ago Up 11 minutes 0.0.0.0:3000->3000/tcp
- Access docker container using CONTAINER ID above
docker exec -it 902293b368b3 bash
- Run test inside docker container
node@902293b368b3:~/app$ npm run test
docker build -t pointhub/papi-starter .