Giter Club home page Giter Club logo

task02's Introduction

TASK2-API

Setup

This API was created using Golang. To setup the API on your local machine, ensure you have installed at least the go version specified in the go.mod file. Clone the repo and run go mod tidy.

Running the API

  • Run go build ..
  • Run ./main. If the server starts and successfully connects to the database, the string Fiber will be logged in the terminal.

Usage

Live base url: [https://task02-ann404014.b4a.run/api]

Create person

This is the endpoint that is used to add a new person to the database.

  • URL

    /api

  • Method

    POST

  • Request Body

    Required
    name=[string]

    Example:

    {
      "name": "habeeb"
    }
  • Success Response

    Returns the ID of the newly created document and the name.

    Status Code: 200

    {
      "ID": 1,
      "name": "habeeb"
    }

Retrieve person

This is the endpoint that is used to retrieve the document whose ID value in the database corresponds to the userID URL parameter.

  • URL

    /api/{userID}

  • Method

    GET

  • URL Parameter

    Required
    userID=[int]

  • Example

    /api/1
  • Success Response

    Status Code: 200

    {
      "ID": 1,
      "name": "habeeb"
    }
  • Error Reponse

    When the provided userID does not match any document in the database.

    Status Code: 200

    {
      "error": "No row with found with that id"
    }

Edit person

This is the endpoint that is used to change the details of the document whose ID corresponds with userID.

  • URL

    /api/{userID}

  • Method

    PATCH

  • Request Body

    Required
    name=[string]

  • Example

    URL

    /api/1

    Body

    {
      "name": "lawal"
    }
  • Success Response

    Status Code: 200

    {
      "ID": "1",
      "name": "habeeb"
    }
  • Error Reponse 1

    When the provided userID doesn't match any row in the database.

    Status Code: 200

    {
      "error": "No row with found with that id"
    }
  • Error Response 2

    When the body of the request cannot be parsed

    Status Code: 200

    {
      "error": "Failed to parse body"
    }
  • Error Response 3

    When the provided userID is not a valid integer.

    Status Code: 200

    {
      "error": "Cannot parse the ID from query"
    }

Delete person

This is the endpoint that is used to remove the person document with the corresponding userID from the database.

  • URL

    /api/{userID}

  • Method

    DELETE

  • Success Response

    Status Code: 200

    {
      "message": "name of the person with that id"
    }
  • Error Reponse 1

    When the provided userID is not a valid integer.

    Status Code: 200

    {
      "error": "Cannot parse the ID from query"
    }
  • Error Reponse 2

    When the provided userID doesn't match any row in the database.

    Status Code: 200

    {
      "error": "No row with found with that id"
    }

Link to test

UML Diagram

UML Diagram

ER Diagram

ER Diagram

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.