Giter VIP home page Giter VIP logo

pms-api's Introduction

Build Status

Population Management API

Population Management application provides REST API endpoints for a population management system. It allows create, retrieve, update and delete actions to be carried out.

API Documentation

The API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API status and errors. Go to documentation

Features

Location:

  • The following can be carried out:
    • Create Location with population: Parent Location and Sub-Parent location can be created by passing in the following values to a POST request via /api/location.

    Create Parent Location

        "name": "Abuja",
        "parentId": null or "" ,
        "male": 2,
        "female": 4
      }
    

    Create sub Parent Location

        "name": "Abuja",
        "parentId": 94 ,
        "male": 2,
        "female": 4
      }
    
    • Retrieve All Locations: Get all locations by calling a GET request via /api/locations.
    • Update location: You can update locations and its residents by the location Id.

    Provide the fields below then call a PUT request via /api/locations/:id the id is the location id you want to update

    {
    "name": "Abuja", //location name
    "male": 2, //male resident number
    "female": 4 //female resident number
    }
    
    • Delete Location: You can delete location by Id if the Id matches the location id by call calling a DELETE request via /api/locations/:id.

Development

This API is built with the following technologies;

Installation

  • Install NodeJs and Postgres on your machine
  • Clone the repository $ git clone https://github.com/iakhator/pms-api.git
  • Change into the directory $ cd /pms-api
  • Install all required dependencies with $ npm install

Set up Database

  • run psql postgres --u postgres to login into postgres
  • create a role CREATE ROLE <username> WITH LOGIN PASSWORD '<password>';
  • alter the role for the new user ALTER ROLE <username> CREATEDB;
  • quit postgres \q
  • run psql postgres -U <username>;
  • next create the database using postgres=> CREATE DATABASE <database>;
  • grant user all priivileges to database postgres=> GRANT ALL PRIVILEGES ON DATABASE <database> TO <username>;
  • quit postgres \q
  • Create a .env file in your root directory as described in .env-sample file and replace the data with the database credentials you just created
  • run migration sequelize db:migrate

Start for development/Local

npm start
it should run on `localhost:3000`

Documentation

Run on `localhost:3000/api-docs`

Testing api with Swagger

  • To test on local
open `swagger.json` change `host` to `host:localhost:3000`
change `https` to `http` in `localhost:3000/api-docs`

Testing

  • Open a terminal and navigate to the project directory
  • Add a test database url (DATABASE_URL) to the .env file.(optional)
  • Run npm test

LICENSE

This project is authored by Itua Akhator it is licensed under the MIT license.

pms-api's People

Contributors

dependabot[bot] avatar iakhator avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.