GithubHelp home page GithubHelp logo

masihtehrani / books Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 125 KB

simple api project based on clean architecture

License: GNU General Public License v3.0

Shell 0.34% Makefile 6.03% Go 91.60% PLpgSQL 2.03%

books's Introduction

Book Sore

made-with-Go CodeFactor GitHub go.mod Go version of a Go module GoReportCard example

Installation

  1. export environmental variables, environmental variables are stored in .env file. Run export $(cat ./.env | xargs)

  2. Run make migrate-up to create database migrations.

  3. Run make Run to build and run the project on prot and ip that are sets in .env file.

Architecture

Project develop based on clean architecture Robert C.Martin ("Uncle Bob").

Endpoints

Version

curl --location --request GET 'http://127.0.0.1:6000/version'

response

{
    "tag": "677b9e4e74162b6ff897830992f5534a86a99801",
    "commit": "677b9e4",
    "date": "2021-06-15T09:17:19+04:30",
    "service": "books"
}

Sign-up

curl --location --request POST 'http://127.0.0.1:6000/sign-up' \
--header 'Content-Type: application/json' \
--data-raw '{
"full_name":"",
"pseudonym":"",
"username":"",
"password":""
}'

response

{
    "success": true
}

Sign-in

curl --location --request POST 'http://127.0.0.1:6000/sign-in' \
--header 'Content-Type: application/json' \
--data-raw '{
    "username":"",
    "password":""
}'

response

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNDNiZTYyOWEtMmZkNC00YWQ4LTkwNTMtMzMyZGRkN2JiZmE2IiwiZXhwIjoxNjIzNzY0MTYzfQ.x1XY4YbwEfEexKPBW5q1qLq4mvIg8e-szoP2aXT2kMU",
    "expire_at": "2021-06-15T18:06:03.081707+04:30"
}

Create Book

curl --location --request POST 'http://127.0.0.1:6000/books' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiOGM2ZTdhODYtNGUwYi00MDU3LWI1YzEtOTU5MWNlOWQwZThhIiwiZXhwIjoxNjIzMzMxNDk3fQ.6aAoIWgvOECERzbsspazqEanWaHPs70mIgO4jdvN2ps' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title":"",
    "description":"",
    "is_published": true
}'

response

{
    "Success": true
}

Get Books

curl --location --request GET 'http://127.0.0.1:6000/books'

response

{
    "data": [
        {
            "id": "1b0f86b7-fb9d-4469-9b96-b5cb5f9b02f2",
            "title": "The Man Who Laughs",
            "description": "The Man Who Laughs is a novel by Victor Hugo, originally published in April 1869 under the French title L'Homme qui rit. It takes place in England in the 1680s and 1700s, during the reigns of James II and Queen Anne, respectively, and depicts England's royalty and aristocracy of the time as cruel and power-hungry.",
            "is_published": true,
            "author_full_name": "Victor Hugo",
            "author_pseudonym": "Hugo",
            "created_at": "2021-06-15T17:07:41Z"
        },
        {
            "id": "533cc88d-1ad7-42e2-930c-fc4ee5f41274",
            "title": "Bug-Jargal",
            "description": "Bug-Jargal is a novel by the French writer Victor Hugo. First published in 1826, it is a reworked version of an earlier short story of the same name published in the Hugo brothers' magazine Le Conservateur littéraire in 1820.",
            "is_published": true,
            "author_full_name": "Victor Hugo",
            "author_pseudonym": "Hugo",
            "created_at": "2021-06-15T08:46:16Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 10,
        "last_page": 1,
        "total": 2
    }
}

Update Book

curl --location --request PUT 'http://127.0.0.1:6000/books/:id' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiOGM2ZTdhODYtNGUwYi00MDU3LWI1YzEtOTU5MWNlOWQwZThhIiwiZXhwIjoxNjIzNjM5MDA5fQ.1xnWPG6HCtOABp0R-p9WcS7BQGrfFaIAtGE0O0FapbQ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title":"",
    "description":"",
    "is_published": false
}'

response

{
    "Success": true
}

Delete Book

curl --location --request DELETE 'http://127.0.0.1:6000/books/:id' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNDNiZTYyOWEtMmZkNC00YWQ4LTkwNTMtMzMyZGRkN2JiZmE2IiwiZXhwIjoxNjIzNzY0MTYzfQ.x1XY4YbwEfEexKPBW5q1qLq4mvIg8e-szoP2aXT2kMU' \
--data-raw ''

response

{
    "Success": true
}

Project linted

project linted by golangci-lint has version 1.40.1

books's People

Contributors

masihtehrani avatar

Stargazers

 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.