Population management API The API provides a user a way to view a list of locations and the breakdown of the population based on gender.
- git clone https://github.com/Collins33/Population-management-API.git
- cd into the project folder
- run
npm install
- create an account on mongo DB atlas
- create a mongo atlas database
- ensure the IP security settings allow connctions from everywhere
- copy the connection url given to you.
- create nodemon.json file
- add the database connection given to you
"MONGO_DATABASE_URL": "database url given"
- run
npm start
- create test database on mongo atlas
- ensure the IP security settings allow connctions from everywhere
- save the database url given
"MONGO_DATABASE_TEST_URL":"test database url given"
- run
npm test
Endpoint | FUNCTIONALITY |
---|---|
POST /api/v1/locations | This will create the location |
GET /api/V1/locations | This will get all the locations |
GET /api/V1/locations/:locationId | This will get an individual location |
PUT /api/V1/locations/:locationId | This will edit a specific location |
DELETE /api/V1/locations/:locationId | This will delete a location |
Payload
{
"name": "Nairobi",
"femalePopulation": 400000,
"malePopulation": 40000,
}
Response
{
"message": "Location was created",
"createdLocation": {
"name": "Nairobi",
"femalePopulation": 400000,
"malePopulation": 40000,
"totalPopulation": 440000,
"_id": "5d5e53bf0060d20004bb3806",
"request": {
"type": "GET",
"description": "Get the created location",
"url": "https://population-control-33.herokuapp.com/api/v1/locations/5d5e53bf0060d20004bb3806"
}
}
}
- NODE/EXPRESS - The web framework used
- npm - Dependency Management
- Mongo Atlas-Database
- COLLINS NJAU MURU
This project is licensed under the MIT License