This a Node.js project, developed by Typescript.
- Just copy
.env.example
to.env
and fill with your einviorements:
PORT=8000
MONGO_URL=XXXXXXX
- Install npm packages:
npm install
- To run app just call following in your command line:
npm run start:dev
- You can run project on production js too:
npm run start
If you like to run the project with Docker, just run docker-compose
with envs:
PORT=8000 MONGO_URL='mongodb+srv://test:test@example.mongodb.net/test?retryWrites=true' docker-compose up -d
This tests uses mongodb-memory-server
as a MongoDb Driver.
- To run all the tests:
npm test
Base Route: https://localhost:PORT
Route: /
Method: GET
Response
Status: 200
"Hi! I am Getir :)"
Route: /
Method: POST
Body:
{
"startDate": "2020-10-01", //string, with a Date YYY-MM-DD format
"endDate": "2020-12-01", //string, with a Date YYY-MM-DD format
"minCount": 1000, //number
"maxCount": 3000 //number
}
Response
Status: 200
{
"code": 0,
"msg": "Success",
"records": [
{
"key": "AxqGywiF", //string
"createdAt": "2016-11-30T14:47:38.027Z", //string
"totalCount": 2653 //number
},
...
]
}
Yoy will recieve 400
error if you don't pass any one of body parameters with request.
Route: /
Method: POST
Body (Example):
{}
Response
Status: 400
{
"code": 400,
"msg": "Bad Request!",
"error": [
"body[startDate]: must be a date with YYYY-MM-DD fromat",
"body[endDate]: must be a date with YYYY-MM-DD fromat",
"body[minCount]: must be a valid number",
"body[maxCount]: must be a valid number"
]
}
If there were no records based on your query, you will recieve 404
error.
Route: /
Method: POST
Body (Example):
{
"startDate": "2021-01-01", //string, with a Date YYY-MM-DD format
"endDate": "2021-01-01", //string, with a Date YYY-MM-DD format
"minCount": 4500, //number
"maxCount": 5000 //number
}
Response
Status: 404
{
"code": 404,
"msg": "There is no record!",
"records": []
}