Skip to content

EDU-API is for the EDU Q&A platform where people can ask questions andprovide responses.

License

Notifications You must be signed in to change notification settings

outboxafrica/edu_prepvii_benz

Repository files navigation

EDU API (PREP VII BENZ) Run tests

Table Of Contents

  1. Project Overview
  2. Usage
    1. Pre-requisites
  3. Contributors

Project Overview

EDU-API is for the EDU Q&A platform where people can ask questions andprovide responses.

Environment Variables

  • PORT -- server port number

  • DB_URL -- database URL

  • SECRET -- Secret key for verifying the token

  • NODE_ENV -- Specifies the Server environment (development, local, production)

Usage

  • clone this repository.

  • cd into project root directory.

  • run npm install to install all dependencies. (you must have pre-requisites)

  • Run npm start to start the server.

  • Open up Postman and then test out the Endpoints.

Pre-requisites

User CRUD Operations

Create a User

Adds in a new single user into the Application.

End Point Method Params Data Type
/api/v1/auth/signup POST none none
  • Request Body
{
  "username": "testuser",
  "email": "[email protected]",
  "password": "password"
}
  • Request Headers

None

  • Success Response:

Status: 200 OK

  • Sample Content:
{
  "Message": "User account succesfully created!",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
  eyJpZCI6IjVmNTc2OTlmM2U4NjFjMDAxNzBhNTFhMSIsImlhdCI6MTU5OTU2NDE5MSwiZXhwIjoxNTk5NjUwNTkxfQ.
  Hkp5ruXBMYdJ4pYdQCIJbKfB5PU6hdss5lEXehtNGUc"
}
  • Error Response
{
  "status": 422,
  "message": "an error occured"
}

Login User

Logs in a single user into the Application

End Point Method Params Data Type
/api/v1/auth/login POST none none
  • Request Body
{
  "username": "testuser",
  "password": "password"
}
  • Response Body
{
  "message": "logged In",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
  .eyJ1c2VybmFtZSI6ImthbGx5IiwicGFzc3dvcmQiOiJwYXNzd29yZCIsImlhdCI6MTYwMDc4Mjc3MywiZXhwIjoxNjAwODY5MTczfQ
  .TfG4lq7AZtWU6ES332_boK6eGdiexPH7eb3IxhXVL2k"
}
  • Validation Error Response for Email Missing field
{
  "message": "\"username\" is required"
}
  • validation Error Response for Password Missing field
{
  "message": "\"email\" is required"
}

Get User By ID

Returns a single user by their Id

End Point Method Params Data Type
/api/v1/user/:id GET none none
  • Request Headers

{ Authorisation: Bearer Token}

Returns user object

Contributors

  1. Iden
  2. Dipan
  3. Jane Aguti
  4. A. Isaac
  5. S. Samuel
  6. S. Akullu

Leading Facilitator

David Buyinza

License

MIT

About

EDU-API is for the EDU Q&A platform where people can ask questions andprovide responses.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published