This is a node.js app that depends on the following technologies.
Express.js: A fast, opinionated, minimalist web framework for node which was used in routing this application.
BodyParser: This module was used to collect search data sent from the client side to the routing page.
MongoDB: A NOSQL document-driven database
Mongoose: A schema-based solution to model your application data
- Navigate to the directory you want it installed to. cd your folder
- Clone the repository https://github.com/HawiCaesar/population-management-system.git.
- Create an account, users and databases on Mlab
- Create 2 databases(test and development).
- Navigate the population-management-system folder.
- Create a .env file using the .env.example as a guide.
yarn install
to install all dependencies.yarn start
- The app runs on port 8000yarn test
runs all the tests.
EndPoint | Functionality |
---|---|
POST /api/locations/ | Create a new location. |
GET /api/locations | Get all locations. |
GET /api/location/:locationId | Get a single location |
PUT /api/location/:locationId | Update a location |
DELETE /api/location/:locationId | Delete a specific location |
{
"name": "Nyali",
"male": 46,
"female": 36,
"parentLocation": "5c9e0af4ab51f04aa8071c93" // optional to infer location is a sublocation
}
{
"message": "Location created",
"location": {
"_id": "5c9e35066e84686b637363fc",
"name": "Kisumu",
"male": 4600,
"female": 3600,
"__v": 0
}
}
[
{
"_id": "5c9c78fd9f0e84f258a4a648",
"name": "Nyali",
"male": 46,
"female": 36,
"parentLocation": "5c9e0af4ab51f04aa8071c93",
"totalResidents": 82
},
{
"_id": "5c9e0af4ab51f04aa8071c93",
"name": "Mombasa",
"male": 4500,
"female": 3600,
"totalResidents": 8100
},
{
"_id": "5c9e35066e84686b637363fc",
"name": "Kisumu",
"male": 4600,
"female": 3600,
"totalResidents": 8200
}
]
{
"_id": "5c9c78fd9f0e84f258a4a648",
"name": "Nyali",
"male": 46,
"female": 36,
"parentLocation": "5c9e0af4ab51f04aa8071c93",
"__v": 0
}
{"male": 47}
{
"_id": "5c9c78fd9f0e84f258a4a648",
"name": "Nyali",
"male": 47,
"female": 36,
"parentLocation": "5c9e0af4ab51f04aa8071c93",
"__v": 0
}
status code 204