GithubHelp home page GithubHelp logo

parviz-yu / todoapp Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 33 KB

:white_check_mark: REST API for providing data from the server

Makefile 1.62% Go 98.38%
golang gorilla-mux gorilla-sessions postgresql restapi-backend logrus godotenv ozzo-validation testify

todoapp's Introduction

REST-API TodoApp

«TodoApp» is a convenient REST API for providing data from the server to the user of a web application or website.

Installation

To build TodoApp from source, simply run git clone https://github.com/pyuldashev912/TodoApp and cd into the project source directory. Then run make. After this, you should have a binary called todoapp in the current directory.

$ make
go build -v ./cmd/todoapp
...

It is assumed that you are using PostgreSQL. Create a new database using createdb todoapp. Add the following application configurations to .env file into the project source directory:

BIND_ADDR = ":8080"
LOG_LEVEL = "info"
DATABASE_URL = "host=localhost dbname=todoapp sslmode=disable"
SESSION_KEY = "<generate session key>"

Launch the application

$ ./todoapp
INFO[0000] Listening...

Endpoints

Create a user

Request

POST /sign-up

http POST localhost:8080/sign-up name=name email=email password=password

Response

{
    "id": int,
    "name": string,
    "email": string,
}

Login

Request

POST /sign-in

http --session=user POST localhost:8080/sign-in email=email password=password

Response

{
    "info": string
}

Logout

Request

POST /users/logout

http --session=user POST localhost:8080/users/logout

Response

{
    "info": string
}

Who am I

Request

GET /users/me

http --session=user GET localhost:8080/users/me

Response

{
    "id": int,
    "name": string,
    "email": string,
}

Create a task

Request

POST /users/tasks

http --session=user POST localhost:8080/users/tasks title="Some task" description="Some text"

Response

{
    "id": int,
    "title": string,
    "description": string,
    "done": bool,
    "creation_date": string
}

Get task

Request

GET /users/tasks/id

http --session=user GET localhost:8080//users/tasks/id"

Response

{
    "id": int,
    "title": string,
    "description": string,
    "done": bool,
    "creation_date": string
}

Get done/underdone tasks

Request

GET /users/tasks?done=true/false

http --session=user GET localhost:8080/users/tasks?done=true"

Response

[
    {
        "id": int,
        "title": string,
        "description": string,
        "done": bool,
        "creation_date": string
    }
    ...
]

Get all tasks

Request

GET /users/tasks

http --session=user GET localhost:8080/users/tasks"

Response

[
    {
        "id": int,
        "title": string,
        "description": string,
        "done": bool,
        "creation_date": string
    }
    ...
]

Mark the task as completed

Request

PATCH /users/tasks/id

http --session=user PATCH localhost:8080/users/tasks/id"

Response

{
    "info": string
}

Delete the task

Request

DELETE /users/tasks/id

http --session=user delete localhost:8080/users/tasks/id"

Response

{
    "info": string
}

todoapp's People

Contributors

parviz-yu avatar

Watchers

 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.