users

package module
v0.1.2-0...-cc8761f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2020 License: GPL-3.0 Imports: 2 Imported by: 19

README

Users-API

Microservice implemented in Golang that stores user information into Postgres database.

Table

   Column   |           Type           | Collation | Nullable |      Default
------------+--------------------------+-----------+----------+-------------------
 id         | uuid                     |           | not null | gen_random_uuid()
 email      | character varying(255)   |           | not null |
 name       | character varying(255)   |           | not null |
 password   | character varying(255)   |           | not null |
 created_at | timestamp with time zone |           |          | now()
 updated_at | timestamp with time zone |           |          | now()
 deleted_at | timestamp with time zone |           |          |
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)
    "users_email_key" UNIQUE CONSTRAINT, btree (email)
Triggers:
    update_users_update_at BEFORE UPDATE ON users FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column()

gRPC Service

message User {
  string id = 1;
  string email = 2;
  string name = 3;
  string password = 4;

  int64 created_at = 5;
  int64 updated_at = 6;
}

service UsersService {
  rpc Get(GetRequest) returns (GetResponse) {}
  rpc GetByEmail(GetByEmailRequest) returns (GetByEmailResponse) {}
  rpc Create(CreateRequest) returns (CreateResponse) {}
  rpc VerifyPassword(VerifyPasswordRequest) returns (VerifyPasswordResponse)  {}
  rpc List(ListRequest) returns (ListResponse) {}
  rpc Update(UpdateRequest) returns (UpdateResponse) {}
  rpc Delete(DeleteRequest) returns (DeleteResponse) {}
}

Environments Values

PORT: define users service port.

HOST: define users service host.

POSTGRES_DSN: define postgres database connection DSN.

Commands (Development)

make build: build users service for osx.

make linux: build users service for linux os.

make docker: build docker.

make compose: start docker-docker.

make stop: stop docker-docker.

make run: run users service.

docker run -it -p 5020:5020 users-api: run docker.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Events

type Events struct {
	BeforeCreate func() error
	AfterCreate  func() error
}

Events ...

type Query

type Query struct {
	ID    string
	Email string
}

Query ...

type Service

type Service interface {
	GetByID(id string) (*User, error)
	GetByEmail(email string) (*User, error)
	Create(*User) error
	UserList() ([]*User, error)
	Update(*User) error
	Delete(*User) error
}

Service ...

type User

type User struct {
	ID string `json:"id" db:"id"`

	Email    string `json:"email,omitempty" db:"email"`
	Name     string `json:"name,omitempty" db:"name"`
	Password string `json:"password,omitempty" db:"password"`
	Verified bool   `json:"verified" db:"verified"`

	CreatedAt time.Time  `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt time.Time  `json:"updated_at,omitempty" db:"updated_at"`
	DeletedAt *time.Time `json:"-,omitempty" db:"deleted_at"`
}

User ...

func (*User) FromProto

func (u *User) FromProto(uu *pb.User) *User

FromProto ...

func (*User) ToProto

func (u *User) ToProto() *pb.User

ToProto ...

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL