Skip to content

Golang api made for library system. Clean Architecture has been used.

Notifications You must be signed in to change notification settings

melikesenacakir/GoLibraryAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Usage

This API is designed for library systems. There are User,Book and Borrow endpoints.

Fiber framework, Goose, POSTGRESQL DB, SQLC and Docker was used by developing this API. Also Clean architecture has been used.

Contents

Log Into Accounts

  POST /api/v1/login

Required:

Parameter Type Explanation
role string Enter role(admin/user)
username string Enter username
password string Enter password

-Default Admin Login Informations:

      {
	 "role":"admin",
	 "username":"admin121",
	 "password":"123456"
      }

Response STATUS 200:OK

    {
        "role":"admin",
        "username":"admin121",
        "password":"123456"
    }

Users

Get Users

  GET /api/v1/user

Required:

 Logged into an existing Admin account

Response STATUS 200:OK

    [
        {
            "role": "admin",
            "username": "admin121"
        }
    ]

Get User

  GET /api/v1/user/id

Required:

- Logged into an existing Admin account
Parameter Type Explanation
id int Enter id

Response STATUS 200:OK

    [
        {
            "role": "admin",
            "username": "admin121"
        }
    ]

Create User

  POST /api/v1/user/create

Required:

- Logged into an existing Admin account
Parameter Type Explanation
role string Enter role(admin/user)
username string Enter username
password string Enter password

Response STATUS 200:OK

    {
       "message": "user successfully created"
    }

Delete User

  DELETE /api/v1/user/delete/id

Required:

- Logged into an existing Admin account
Parameter Type Explanation
id int Enter id to url

Response STATUS 200:OK

    {
       "message": "user successfully deleted"
    }

Update User

  PUT /api/v1/user/update/id

Required:

- Logged into an existing Admin account
Parameter Type Explanation
id int Enter id to url
role string Enter role(admin/user)
username string Enter username
password string Enter password

Response STATUS 200:OK

    {
       "message": "user successfully updated"
    }

Books

Get Books

  GET /api/v1/book

Response STATUS 200:OK

    [
        {
            "id": 1,
            "name": "tanios kayası",
            "author": "amin maalouf",
            "stock": 5
        }
    ]

Get Book

  GET /api/v1/book/id

Required:

Parameter Type Explanation
id int Enter id to url

Response STATUS 200:OK

    [
        {
            "id": 1,
            "name": "tanios kayası",
            "author": "amin maalouf",
            "stock": 5
        }
    ]

Create Book

  POST /api/v1/book/create

Required:

- Logged into an existing Admin or User account
Parameter Type Explanation
id int Enter id to url

Response STATUS 200:OK

    [
        {
            "id": 1,
            "name": "tanios kayası",
            "author": "amin maalouf",
            "stock": 5
        }
    ]

Delete Book

  DELETE /api/v1/book/delete/id

Required:

- Logged into an existing Admin or User account
Parameter Type Explanation
id int Enter id to url

Response STATUS 200:OK

    {
       "message": "book successfully deleted"
    }

Update Book

  PUT /api/v1/book/update/id

Required:

- Logged into an existing Admin or User account
Parameter Type Explanation
id int Enter id to url
name string Enter name
author string Enter author
stock int Enter stock

Response STATUS 200:OK

    {
       "message": "book successfully updated"
    }

Borrows

Get Borrows History

  GET /api/v1/borrows/history

Required:

- Logged into an existing Admin or User account

Response STATUS 200:OK

    [
        {
            "borrow_id": 1,
            "borrowdate": "2024-04-28T23:24:35.212264Z",
            "returndate": "2024-05-08T23:24:35.212265Z",
            "status": "borrowed",
            "username": "admin121",
            "book_name": "tanios kayası"
        },
        {
            "borrow_id": 2,
            "borrowdate": "2024-04-28T23:24:35.212264Z",
            "returndate": "2024-05-08T23:24:35.212265Z",
            "status": "returned",
            "username": "user",
            "book_name": "tanios kayası"
        }
    ]

Return Borrowed Book

  PUT /api/v1/borrows/return/id

Required:

- Logged into an existing Admin or User account
Parameter Type Explanation
id int Enter id to url

Response STATUS 200:OK

    {
      "message": "book returned"
    }

Borrow Book

  POST /api/v1/borrows/new

Required:

- Logged into an existing Admin or User account
Parameter Type Explanation
user_id int Enter user id
book_id int Enter book id

Response STATUS 200:OK

    {
       "message": "books successfully borrowed. Please return on time!"
    }

Get Return History

  GET /api/v1/borrows/oldborrows

Required:

- Logged into an existing Admin or User account

Response STATUS 200:OK

    [
        {
            "borrow_id": 1,
            "borrowdate": "2024-04-28T23:24:35.212264Z",
            "returndate": "2024-05-08T23:24:35.212265Z",
            "status": "returned",
            "username": "admin121",
            "book_name": "tanios kayası"
        }
    ]

About

Golang api made for library system. Clean Architecture has been used.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published