NodeJS project that using MongoDB
- First of all, clone the project
git clone https://github.com/peacecwz/nodejs-mongo
- Configure database configuration. You need to run MongoDB and add connection string into src/configs/config-keys.ts file
const DEV: IConfigSet = {
DEBUG_LOGGING_ENABLED: false,
MONGODB_CONNECTION_STRING: "connection-string"
};
If the app is running on heroku, aws or kubernetes, you should set mongodb connection string as MONGODB_CONNECTION_STRING key on environment
- Run the application
Running on local debugging
yarn start:dev
Running on server
yarn build; yarn start
https://nodejs-mongo-demo.herokuapp.com/
You can send request on swagger
?startDate=2016-09-06T13:19:42.679Z
&endDate=2016-11-16T15:43:53.579Z
&minCount=0
&maxCount=100
{
"startDate": "2016-09-06T13:19:42.679Z",
"endDate": "2016-11-16T15:43:53.579Z",
"minCount": 0,
"maxCount": 100
}
curl --location --request GET 'http://nodejs-mongo-demo.herokuapp.com/v1/collections/?startDate=2016-09-06T13:19:42.679Z&endDate=2016-11-16T15:43:53.579Z&minCount=0&maxCount=100'
curl --location --request POST 'http://nodejs-mongo-demo.herokuapp.com/v1/collections/filter' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Content-Type: text/plain' \
--data-raw '{
"startDate": "2016-09-06T13:19:42.679Z",
"endDate": "2016-11-16T15:43:53.579Z",
"minCount": 0,
"maxCount": 100
}'
Run unit tests
yarn unit-tests
Run integration tests
yarn integration-tests
Deploying to Heroku platform, installed Heroku CI & CD. You can see deployments on Github environment