Skip to content

An example todo app using gRPC/REST and PostgresQL in a few lines of code

License

Notifications You must be signed in to change notification settings

mariaefi29/todo-grpc

Repository files navigation

todo-grpc

Todo app with gRPC/REST with the goal of using the least amount of source code with an extended feature set.

Development Environment

  • go >= v1.9
  • git
  • gnu-make
  • grpc (libprotoc >= 3.5.0)

Setup

Makefile

setup                          install dependencies
generate                       generate protobuf files
lint                           run gometalinter
build                          build the go packages

Usage

NAME:
   todo-grpc - Todo app

USAGE:
   todo-grpc [global options] command [command options] [arguments...]

VERSION:
   0.0.0

COMMANDS:
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --bind-http value    bind address for HTTP (default: "0.0.0.0:8080") [$BIND_HTTP]
   --bind-grpc value    bind address for gRPC (default: "0.0.0.0:2338") [$BIND_GRPC]
   --db-name value      database name (default: "todo") [$DB_NAME]
   --db-user value      database username (default: "postgres") [$DB_USER]
   --db-password value  database password [$DB_PASSWORD]
   --db-host value      postgres host (default: "127.0.0.1") [$DB_HOST]
   --db-port value      database port (default: 5432) [$DB_PORT]
   --help, -h           show help
   --version, -v        print the version

Rest API

  • Create a new Todo:
$ curl -X POST -H "Content-Type: application/json" -d '{"title":"Test","description":"Test"}' "http://localhost:8080/v1/todo"
{"id":"34d63bd4-56b3-4795-80d4-86e5db6fa0b5"}
  • Get an existing Todo:
$ curl -X GET "http://localhost:8080/v1/todo/34d63bd4-56b3-4795-80d4-86e5db6fa0b5"
{"item":{"id":"34d63bd4-56b3-4795-80d4-86e5db6fa0b5","title":"Test","description":"Test","created_at":"2018-03-30T20:13:25.291887Z"}}
  • Update a Todo:
$ curl -X PUT -H "Content-Type: application/json" -d '{"id": "34d63bd4-56b3-4795-80d4-86e5db6fa0b5", "title":"TestBis", "description":"TestBis", "completed": "true"}' "http://localhost:8080/v1/todo"
{}
  • Delete a Todo:
$ curl -X DELETE "http://localhost:8080/v1/todo/34d63bd4-56b3-4795-80d4-86e5db6fa0b5"
{}
  • Bulk Insert Todos:
curl -X POST -H "Content-Type: application/json" -d '{"items": [{"title":"Todo_1","description":"Todo_1"},{"title":"Todo_2","description":"Todo_2"}]}' "http://localhost:8080/v1/todo/bulk"
{"ids":["e8924469-8847-4840-ae16-21be734173f4","0db11e34-4707-4a5d-92fe-f4952213d940"]}

Language/Libraries

  • golang
  • grpc-gateway
  • go-grpc-middleware
  • postgresql (access through go-pg orm)
  • gRPC: Protocol buffers v3 (documentation)

About

An example todo app using gRPC/REST and PostgresQL in a few lines of code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 87.1%
  • Makefile 12.9%