Skip to content

Build a fullstack application with vanilla js, css ,raw sql, node js. Implement tdd and code metrics using agile methods

Notifications You must be signed in to change notification settings

Cea-Personal/Politico

Repository files navigation

Build Status Maintainability Test Coverage Coverage Status

Politico API

Politico API is a REST API that is used for a voting , modelling the current voting scenario of any country.

  • Politico API is currently hosted on Heroku

Table of Content

** To install this API on your local device **

  • Copy the Git Clone Link the API on your local Git
  • Run npm install on local git
$ cd ../politico
$ git clone https://github.com/basilcea/politico.git
$ npm run install
$ npm run migrate createAllTables
$ npm run dev

Testing With Postman (#head2)

Testing locally

On your desktop or Laptop
- Create a Postgres database on Port 5433 with name ** Politico **
- Select the HTTP Method (GET, POST, PATCH, DELETE) on Postman
- Test your API on localhost:3000/api/v1/<route>
- On Postman click on Authorization, Select Bearer Token
- For unauthenticated routes put null as value for token
- For aunthenticated routes input the outputed token.

Testing on Heroku

On your desktop or laptop
- Open Postman app on your local device
- Select the HTTP Method (GET, POST, PATCH, DELETE) on Postman
- Test your API on https://cea-politico-gres.herokuapp.com/<route>
- On Postman click on Authorization, Select Bearer token
- For unauthenticated routes put null as value for token
- For aunthenticated routes input the outputed token.

Endpoints (#head3)

The endpoints below are divided into 7 categories.

The endpoint specified below in the format of METHOD .

Users Endpoints

Endpoints are accessable without token authentication or immediately after login.

- POST </auth/signup> - Signup and automatic login.
- POST </auth/login> - Login after logout.
- POST </auth/forgot> - Send a reset link to email address where email exists in database.
- POST </auth/reset> - Change forgotten password via link before login.
- GET </auth/decrypt> - Decrypt user token.
- GET </auth/logout> - Blacklist token on logout using Redis until token expiry.

Activity Endpoints

Endpoints for activity carried by user on login

- GET </users/me> - Get user profile.
- PATCH </users/me/edit> - Edit user profile.
- PATCH </users/me/password> - Change user password after login.
- GET </users/me/votes> - Get all voting activities.
- DELETE </users/me> - Delete Profile.

Offices Endpoints

Endpoints for offices activities
- POST </offices> - Create Office   - * Admin only *.
- GET </offices> - Get all offices.
- GET </offices/:id> - Get a specific office.
- PATCH </offices/:id> - Edit a specific office detail - *Admin only *.
- POST </offices/:id/register> - Register candidate for this office - * Admin only *.
- GET </offices/:id/candidates> - Get all candidates for an office.
- GET </offices/:id / result> - Get all voting results for an office.
- DELETE <offices/:id> - Delete an office - *Admin only*.

Vote Endpiont

- POST </votes> - Vote a user for an office.

Party Endpoints

- POST </parties> - Create a party - * Admin only *.
- GET </parties> - Get all parties.
- GET </parties/:id> - Get a specific party.
- PATCH </parties/:id> -Edit a party detail - * Admin only *.
- DELETE </parties/:id> - Delete a party - *Admin only *.

Candidates Endpoints

- GET </candidates/user/:id> - Get all candidates by candidate id.
- GET </candidates/:id> - Get candidates by user id.
- PUT </candidates/:id> - Edit candidates by user id.
- DELETE </candidates/:id> - Delete candidates by user id.

Interests Endpoints

- GET </interests> - Get all interests.
- POST </interests> - Create an interest.
- PATCH </interests/:id> - Edit an interest.
- DELETE </interests/:id> - Delete an interest.

Petition Endpoints

- GET </petitions> - Get all petitions.
- GET </petitions/:id> - Get a specific petition.
- POST </petitions> - Post a petition.
- PATCH </petitions/id> - Edit a petition.
- DELETE </petitions/:id> - Delete a Petition.

To deploy the API to Heroku

  • Create heroku account
  • Create an app on heroku
  • Git push origin
  • Connect Github repo to Heroku
  • Deploy manually or automatically by selecting the specifice github branch
  • Run APP on heroku.

This API was created by basilcea. API Specification provided by Andela as part of the bootcamp training process.

I want to acknowledge the inputs from two learning facilitators and a host of fellow bootcampers who contributed in no small way to building my building this API.

About

Build a fullstack application with vanilla js, css ,raw sql, node js. Implement tdd and code metrics using agile methods

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published