Code Monkey home page Code Monkey logo

ent-clean-template's Introduction

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"
}

ent-clean-template's People

Contributors

dependabot[bot] avatar tcmits avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.