menekel

package module
v0.0.0-...-adc7e29 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 3 Imported by: 0

README

menekel

menekel /'m(ə)n(ə)k(ə)l/ stands for : menej artikel is a sample of article management services build from Golang.

Index

Contribution

You can file an issue or submit a Pull Request

Testing

Integration Test

$ make test

Unit Test

$ make unittest
Run The Project
# Dockerize the app
$ make docker

# Create the config file
$ cp config.toml.example config.toml

# run the project
$ make run

# Migrate the schema
$ make migrate-prepare
$ make migrate-up

Now the application should be active. Try to access it.

$ curl http://localhost:9090/articles

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternalServerError will throw if any the Internal Server Error happen
	ErrInternalServerError = errors.New("Internal Server Error")
	// ErrNotFound will throw if the requested item is not exists
	ErrNotFound = errors.New("Your requested Item is not found")
	// ErrConflict will throw if the current action already exists
	ErrConflict = errors.New("Your Item already exist")
	// ErrBadParamInput will throw if the given request-body or params is not valid
	ErrBadParamInput = errors.New("Given Param is not valid")
)

Functions

This section is empty.

Types

type Article

type Article struct {
	ID        int64     `json:"id"`
	Title     string    `json:"title" validate:"required"`
	Content   string    `json:"content" validate:"required"`
	UpdatedAt time.Time `json:"updated_at"`
	CreatedAt time.Time `json:"created_at"`
}

Article represent the Article contract

type ArticleRepository

type ArticleRepository interface {
	Fetch(ctx context.Context, cursor string, num int64) (res []Article, csr string, err error)
	GetByID(ctx context.Context, id int64) (res Article, err error)
	GetByTitle(ctx context.Context, title string) (res Article, err error)
	Update(ctx context.Context, article *Article) (err error)
	Store(ctx context.Context, a *Article) (err error)
	Delete(ctx context.Context, id int64) (err error)
}

ArticleRepository represent the repository contract

type ArticleUsecase

type ArticleUsecase interface {
	Fetch(ctx context.Context, cursor string, num int64) (res []Article, csr string, err error)
	GetByID(ctx context.Context, id int64) (res Article, err error)
	Update(ctx context.Context, ar *Article) (err error)
	GetByTitle(ctx context.Context, title string) (res Article, err error)
	Store(context.Context, *Article) (err error)
	Delete(ctx context.Context, id int64) (err error)
}

ArticleUsecase represent the usecase of the article

Directories

Path Synopsis
app
cmd
internal

Jump to

Keyboard shortcuts

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