This API creates a Population Management System that contains a list of locations and the total number of residents in each location broken down by gender.
The project structure follows the MVC (Model-View-Controller) pattern. You can think of the JSON representation of data returned by the API as the 'view'.
├── src/
├── controllers
├── LocationsController.ts
├── helpers
├── validatePayload.ts
├── middlewares
├── validateUserInputs.ts
├── models
├── BaseSchema.ts
├── repositories
├── BaseRepository.ts
├── routers
├── index.ts
├── services
├── LocationService.ts
├── tests
├── home.spec.ts
├── utils
├── db.ts
├── logger.ts
├── app.ts
├── index.ts
├── typings
├── config.d.ts
├── README.md
├── tsconfig.json
- Node.js v10.x or higher
- npm
- MongoDB instance (local or remote)
$ git clone https://github.com/jherey/population_api.git
$ cd population_api
$ npm install
$ npm run dev # For development purpose
$ npm start # To run production build
You should now be able to access the API via http://localhost:2300/api/
NOTE: Create a .env
file configuration following the .env.example
.
Some things to note about the project
- It uses Typescript to ensure type safety.
- The
typings
folder holds custom Typscript type definitions.
HTTP VERB | ENDPOINTS | DESCRIPTION |
---|---|---|
POST | /api/locations | Creates a new location |
GET | /api/locations | Returns available locations |
PUT | /api/locations/:id | Updates a location |
DELETE | /api/locations/:id | Deletes a location |
We welcome contributions, what are you waiting for? Raise a Pull Request!! 😁
This project is licensed under the MIT license.