Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

CSCI-X050-A7/backend

Repository files navigation

Fiber Go Boilerplate

Is a production-ready golang based boilerplate application with Fiber Go web framework. For any fiber go application, just clone the repo & rename the application name.

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.

Tools & Libraries used

⚡️ Quick start

  • Install golang >= 1.21, air, swag, golangci-lint, pre-commit
  • Copy .env.example to .env
    cp .env.example .env
  • Install pre-commit hooks
    pre-commit install
  • Run project by this command:
    air
  • Visit http://localhost:5000 or http://localhost:5000/swagger

🗄 Project structure

/app

Folder with business logic only. This directory doesn't care about what database driver you're using.

  • /app/controller folder for functional controller (used in routes)
  • /app/schema folder for object for API clients
  • /app/model folder for describe business models and methods of your project

/cmd

Main applications for this project.

The directory name for each application should match the name of the executable you want to have (e.g., /cmd/server /cmd/cron). Don't put a lot of code in the application directory. If you think the code can be imported and used in other projects, then it should live in the /pkg directory.

/docs

Folder with API Documentation.

This directory contains config files for auto-generated API Docs by Swagger, screenshots and any other documents related to this project.

/pkg

Folder with project-specific functionality. This directory contains all the project-specific code tailored only for your business use case.

  • /pkg/config folder for configuration functions
  • /pkg/middleware folder for add middleware (Fiber built-in and yours)
  • /pkg/route folder for describe routes of your project
  • /pkg/validator folder with validation functions

/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, logger instance.

  • /platform/database folder with database setup functions (by default, Sqlite)
  • /platform/logger folder with better logger setup functions (by default, Logrus)

⚙️ Configuration

# .env
# APP settings:
HOST="0.0.0.0"
PORT=5000
DEBUG=true

# JWT settings:
JWT_SECRET="super_secret_here"
JWT_EXPIRE_SECONDS=1209600

# Database settings:
DB_FILENAME=sqlite3.db
DB_ECHO=true

⚠️ License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages