Giter Club home page Giter Club logo

my_fiber's Introduction

Fiber backend template for Create Go App CLI

go version go report license

Fiber is an Express.js inspired web framework build on top of Fasthttp, the fastest HTTP engine for Go. Designed to ease things up for fast development with zero memory allocation and performance in mind.

⚡️ Quick start

  1. Create a new project with Fiber:
cgapp create

# Choose a backend framework:
#   net/http
# > fiber
#   chi
  1. Rename .env.example to .env and fill it with your environment values.

  2. Install Docker and the following useful Go tools to your system:

  3. Run project by this command:

make docker.run
  1. Go to API Docs page (Swagger): 127.0.0.1:5000/swagger/index.html

Screenshot

📦 Used packages

Name Version Type
gofiber/fiber v2.34.0 core
gofiber/jwt v2.2.7 middleware
arsmn/fiber-swagger v2.31.1 middleware
stretchr/testify v1.7.1 tests
golang-jwt/jwt v4.4.1 auth
joho/godotenv v1.4.0 config
jmoiron/sqlx v1.3.5 database
jackc/pgx v4.16.1 database
go-sql-driver/mysql v1.6.0 database
go-redis/redis v8.11.5 cache
swaggo/swag v1.8.2 utils
google/uuid v1.3.0 utils
go-playground/validator v10.10.0 utils

🗄 Template structure

./app

Folder with business logic only. This directory doesn't care about what database driver you're using or which caching solution your choose or any third-party things.

  • ./app/controllers folder for functional controllers (used in routes)
  • ./app/models folder for describe business models and methods of your project
  • ./app/queries folder for describe queries for models of your project

./docs

Folder with API Documentation. This directory contains config files for auto-generated API Docs by Swagger.

./pkg

Folder with project-specific functionality. This directory contains all the project-specific code tailored only for your business use case, like configs, middleware, routes or utils.

  • ./pkg/configs folder for configuration functions
  • ./pkg/middleware folder for add middleware (Fiber built-in and yours)
  • ./pkg/repository folder for describe const of your project
  • ./pkg/routes folder for describe routes of your project
  • ./pkg/utils folder with utility functions (server starter, error checker, etc)

./platform

Folder with platform-level logic. This directory contains all the platform-level logic that will build up the actual project, like setting up the database or cache server instance and storing migrations.

  • ./platform/cache folder with in-memory cache setup functions (by default, Redis)
  • ./platform/database folder with database setup functions (by default, PostgreSQL)
  • ./platform/migrations folder with migration files (used with golang-migrate/migrate tool)

⚙️ Configuration

# .env

# Stage status to start server:
#   - "dev", for start server without graceful shutdown
#   - "prod", for start server with graceful shutdown
STAGE_STATUS="dev"

# Server settings:
SERVER_HOST="0.0.0.0"
SERVER_PORT=5000
SERVER_READ_TIMEOUT=60

# JWT settings:
JWT_SECRET_KEY="secret"
JWT_SECRET_KEY_EXPIRE_MINUTES_COUNT=15
JWT_REFRESH_KEY="refresh"
JWT_REFRESH_KEY_EXPIRE_HOURS_COUNT=720

# Database settings:
DB_TYPE="pgx"   # pgx or mysql
DB_HOST="cgapp-postgres"
DB_PORT=5432
DB_USER="postgres"
DB_PASSWORD="password"
DB_NAME="postgres"
DB_SSL_MODE="disable"
DB_MAX_CONNECTIONS=100
DB_MAX_IDLE_CONNECTIONS=10
DB_MAX_LIFETIME_CONNECTIONS=2

# Redis settings:
REDIS_HOST="cgapp-redis"
REDIS_PORT=6379
REDIS_PASSWORD=""
REDIS_DB_NUMBER=0

⚠️ License

Apache 2.0 © Vic Shóstak & True web artisans.

my_fiber's People

Contributors

nguyenthanhquang152 avatar

Watchers

 avatar

my_fiber's Issues

abc

Xét hàm số
$$y = S(x) =  - 2{x^2} + 20x(0 < x < 10)$$
a) Trên mặt phẳng tọa độ Oxy, biểu diễn tọa độ các điểm trong bảng giá trị của hàm số lập được ở Ví dụ 1. Nối các điểm đã vẽ lại ta được dạng đồ thị hàm số
$$y =  - 2{x^2} + 20x$$
trên khoảng (0; 10) như trong Hình 6.10. Dạng đồ thị
$$y =  - 2{x^2} + 20x$$
có giống với đồ thị của hàm số
$$y =  - 2{x^2}$$
hay không?
b) Quan sát dạng đồ thị của hàm số
$$y =  - 2{x^2} + 20x$$
  trong Hình 6.10, tìm tọa độ điểm cao nhất của đồ thị.
c) Thực hiện phép biến đổi
$$y =  - 2{x^2} + 20x =  - 2({x^2} - 10x) =  - 2({x^2} - 2.5.x + 25) + 50 =  - 2{(x - 5)^2} + 50$$
Hãy cho biết giá trị lớn nhất của diện tích mảnh đất được rào chắn. Từ đó suy ra lời giải của bài toán ở phần mở đầu.

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.