Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

peacecwz-archive/nodejs-mongo

Repository files navigation

nodejs-mongo

NodeJS project that using MongoDB

Getting Started

  1. First of all, clone the project
git clone https://github.com/peacecwz/nodejs-mongo
  1. 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

  1. Run the application

Running on local debugging

yarn start:dev

Running on server

yarn build; yarn start

Document

Swaggar

https://nodejs-mongo-demo.herokuapp.com/

You can send request on swagger

[GET] /v1/collections

?startDate=2016-09-06T13:19:42.679Z
&endDate=2016-11-16T15:43:53.579Z
&minCount=0
&maxCount=100

[POST] /v1/collections/filter

{ 
	"startDate": "2016-09-06T13:19:42.679Z", 
	"endDate": "2016-11-16T15:43:53.579Z",
	"minCount": 0,
	"maxCount": 100
}

Example Request

[GET] /v1/collections

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'

[POST] /v1/collections/filter

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
}'

Tests

Run unit tests

yarn unit-tests

Run integration tests

yarn integration-tests

Deployments

Deploying to Heroku platform, installed Heroku CI & CD. You can see deployments on Github environment