ent-clean-template

command module
v0.0.0-...-d93b30e Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 3 Imported by: 0

README

Ent Clean template

Quick start

Local development:

# Run app with migrations
docker compose -f local.yml up

Production:

docker compose -f production.yml up

Integration tests (can be run in CI):

docker compose -f integration_test.yml up --abort-on-container-exit --build --exit-code-from http_v1_integration

Unit tests (can be run in CI):

go test -cover -race $(go list ./... | grep -v /integration_test/)

Generate locale files:

goi18n extract -sourceLanguage=en-US -outdir=./locales/en-US/ -format=yaml ./

Generate docs files:

swag init -g ./internal/controller/http/v1/v1.go -o ./docs/v2

Convert OpenApi v2 to v3 (yaml):

# https://github.com/swaggo/swag/issues/386
docker run --rm -v $(PWD)/docs:/work openapitools/openapi-generator-cli:latest-release \
	  generate -i /work/v2/swagger.yaml -o /work/v3 -g openapi-yaml --minimal-update \
    && mv ./docs/v3/openapi/openapi.yaml ./docs/v3/ \
    && rm ./docs/v3/README.md \
    && rm ./docs/v3/.openapi-generator-ignore \
    && rm -rf ./docs/v3/.openapi-generator \
    && rm -rf ./docs/v3/openapi

Convert OpenApi v2 to v3 (json):

# https://github.com/swaggo/swag/issues/386
docker run --rm -v $(PWD)/docs:/work openapitools/openapi-generator-cli:latest-release \
	  generate -i /work/v2/swagger.json -o /work/v3 -g openapi --minimal-update \
    && rm ./docs/v3/README.md \
    && rm ./docs/v3/.openapi-generator-ignore \
    && rm -rf ./docs/v3/.openapi-generator 
Changing between openapi v2/v3:

Change docs.go

package docs

import _ "github.com/TcMits/ent-clean-template/docs/v3" // replace this
// import _ "github.com/TcMits/ent-clean-template/docs/v2"

Overview

Web framework

Iris is an efficient and well-designed, cross-platform, web framework with robust set of features. Build your own high-performance web applications and APIs powered by unlimited potentials and portability.

Database - ORM

ent is a simple, yet powerful entity framework for Go, that makes it easy to build and maintain applications with large data-models and sticks with the following principles:

  • Easily model database schema as a graph structure.
  • Define schema as a programmatic Go code.
  • Static typing based on code generation.
  • Database queries and graph traversals are easy to write.
  • Simple to extend and customize using Go templates.
File system

go-storage is a vendor-neutral storage library for Go.

Swagger urls
/api/v1/swagger
Default urls

Login endpoint

  • URL

    /api/v1/login

  • Method:

    POST

  • Data Params

{
  "username": "string",
  "password": "string"
}
  • Success Response:

    • Code: 200
      Content:
{
  "access_token": "string",
  "refresh_token": "string",
  "refresh_key": "string"
}
  • Error Response:

    • Code: 400 | 500 | 401
      Content:
{
  "message": "string",
  "code": "string"
}

Refresh token endpoint

  • URL

    /api/v1/refresh-token

  • Method:

    POST

  • Data Params

{
  "refresh_token": "string",
  "refresh_key": "string"
}
  • Success Response:

    • Code: 200
      Content:
{
  "token": "string"
}
  • Error Response:

    • Code: 400 | 500 | 401
      Content:
{
  "message": "string",
  "code": "string"
}

Verify token endpoint

  • URL

    /api/v1/verify-token

  • Method:

    POST

  • Data Params

{
  "token": "string"
}
  • Success Response:

    • Code: 200
      Content:
{}
  • Error Response:

    • Code: 400 | 500 | 401
      Content:
{
  "message": "string",
  "code": "string"
}

Me endpoint

  • URL

    /api/v1/me

  • Method:

    GET | PUT | PATCH

  • Data Params

{
  "username": "string",
  "email": "string",
  "first_name": "string",
  "last_name": "string"
}
  • Success Response:

    • Code: 200
      Content:
{
  "self": "string",
  "id": "string",
  "create_time": "string",
  "update_time": "string",
  "username": "string",
  "first_name": "string",
  "last_name": "string",
  "email": "string",
  "is_staff": "string",
  "is_superuser": "string",
  "is_active": "string"
}
  • Error Response:

    • Code: 400 | 500 | 401
      Content:
{
  "message": "string",
  "code": "string"
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
createuser command
migrate command
v2
Package v2 GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package v2 GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
v3
ent
internal
app
Package app configures and runs application.
Package app configures and runs application.
repository
Package repository is a generated GoMock package.
Package repository is a generated GoMock package.
usecase
Package usecase implements application business logic.
Package usecase implements application business logic.
pkg
infrastructure/httpserver
Package httpserver implements HTTP server.
Package httpserver implements HTTP server.

Jump to

Keyboard shortcuts

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