Giter Club home page Giter Club logo

diego's Introduction

Diego

REST API FRAMEWORK

App Structure :

- app -> all logic of application requirement
    - background -> background service app handler
    - controllers -> controller to consume on route
    - dto_request -> data transfer object request
    - dto_response -> data transfer object response
    - middleware -> middleware of the app
    - models -> model of database
    - repositories -> repository to encapsulation query or fetch data
    - services -> to build logic of the app
    - ucase -> to build specific logic and generate response formatted to consume by route
- config -> configuration app
- pkg -> package usage in app
- provider -> behavior app needed
- route -> app route (api/web)

Application Command Tools

  • Run HTTP server
    <your-app> http serve
    example : my_app http server
  • Run HTTP server on Development/Local Machine
    go run main.go http serve

Installation Diego tools :

Get and install tools from github repo

go install github.com/dienggo/diego/cmd/[email protected]

Check your GOPATH location, windows -> skip this step

go env GOPATH
$ <your-location-gopath>

Copy path and make alias installed diego, example on macos with zsh

alias diego="/<your-location-gopath>/bin/diego"

Example :

alias diego="/usr/development/go/bin/diego"

Use diego

diego -h

Update Diego (beta - available at version >= v1.2.0)

diego update

Diego Command Tools

  • Build New Project

    diego build awesome_project
    awesome_project -> your project name & module
  • Make Controller

    diego generate controller example_case
    example_case -> your controller & controller stored to app/controllers/example_case.go
  • Make UseCase all template

    generate all template of use case [delete.go][detail.go][list.go][upsert.go]
    diego generate ucase example
    exampleCase -> your use case & use case stored to app/ucase/exampleCase
  • Make UseCase partial

    diego generate ucase custom exampleCase
    custom -> your use case & use case stored to app/ucase/exampleCase/custom.go
  • Make Service

    diego generate service example_case
    example_case -> your service & service stored to app/services/example_case.go
  • Make Middleware

    diego generate middleware example_case
    example_case -> your middleware & middleware stored to app/middleware/example_case.go
  • Make Background Service

    diego generate bg-task example_task
    example_task -> your background service & background service stored to app/background/example_task.go
  • Make Command

    diego generate cmd example_case
    example_case -> your command & command stored to cmd/example_case.go & also registered on provider/cmd.go automatically.
    run your command on development/local :
    go run main.go <your-command-name-or-alias>
    example : go run main.go my-command

Migration Tools

Cause this framework depends on goose, install goose first ---> https://github.com/pressly/goose

  • Get help usage
    diego migration -h
  • Migrate the DB to the most recent version available
    diego migration up
  • Migrate the DB up by 1
    diego migration up-by-one
  • Migrate the DB to a specific VERSION
    diego migration up-to VERSION
  • Roll back the version by 1
    diego migration down
  • Roll back to a specific VERSION
    diego migration down-to VERSION
    example : migration down-to 123
  • Re-run the latest migration
    diego migration redo
  • Roll back all migrations
    diego migration reset
  • Dump the migration status for the current DB
    diego migration status
  • Print the current version of the database
    diego migration version
  • Creates new migration file with the current timestamp
    diego migration create NAME [sql|go]
    example : diego migration create your_table sql
  • Apply sequential ordering to migrations
    diego migration fix
  • Check migration files without running them
    diego migration validate

Library Usage

github.com/go-playground/validator/v10 v10.11.1
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/schema v1.2.0
github.com/joho/godotenv v1.4.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.2
github.com/urfave/cli/v2 v2.25.7
golang.org/x/text v0.8.0
gopkg.in/yaml.v2 v2.4.0
gorm.io/driver/mysql v1.3.4
gorm.io/gorm v1.23.7

diego's People

Contributors

daewu14 avatar ahdiyatlalu avatar dienggo avatar dipaferdian avatar muhnashir avatar

Stargazers

Mas tama avatar Adi Primanto avatar  avatar

Watchers

Gontang Ragil Prakasa avatar  avatar

Forkers

daewu14 muhnashir

diego's Issues

command "diego generate service example_case"

I ran the command,
but the file created had an error, namely the ServiceResponse was not imported namespace from [name_project]/pkg/app, and did not use the prefix
app. ServiceResponse

The code is as below

package services

type ExampleCase struct{}

func (s ExampleCase) Do() ServiceResponse {
	//TODO implement me
	panic("implement me")
}

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.