goapisuit

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 14 Imported by: 0

README

Project Logo

goapisuit

Go Reference

goapisuit is a lightweight and easy-to-use Golang framework that simplifies API creation and database management using GoFiber. It aims to accelerate the development of APIs by providing built-in commands for generating models, routers, and handling database migrations.

Features

  • Fast API Creation: Automatically generate routes and models.
  • Database Management: Seamlessly handle migrations with built-in commands.
  • GoFiber Integration: Utilize the powerful and efficient GoFiber web framework.

Getting Started

Prerequisites

To use goapisuit, you need the following installed:

  • Golang
  • A relational database (e.g., MySQL etc.)
  • Git for cloning the repository
Installation
  1. Install CLI heykrit for the goapisuit:

    go install -v github.com/krittakondev/goapisuit/cmd/heykrit@latest
    
  2. Make your project:

    mkdir nameproject
    cd nameproject
    go mod init you/projectpath
    heykrit init
    
  3. Config your project in .env

  4. Run your project:

    go run cmd/server.go
    
Directory Structure

Here's a brief overview of the generated directory structure:

nameproject/
├── cmd/
│   └── server.go        # Entry point of your project
├── internal/
│   ├── models/          # Contains your data models (e.g., user.go)
│   └── routes/             # Contains API route handlers
├── public/              # Directory for static files (e.g., CSS, JavaScript, images)
├── go.mod
└── go.sum
└── .env                 # config project

Usage

Once the setup is complete, you can build upon this project by adding new models and routes using the provided commands. For example, to create a new module for handling products:

  1. Generate a new product Route and Model:

    heykrit make product
    

    Generate 2 files internal/routes/Product.go and internal/models/Product.go

  2. Modify the generated internal/models/Product.go model as needed, and then apply the migration (gorm model):

    heykrit db:migrate product
    
  3. Run server:

    go run cmd/server.go
    

Contributing

If you'd like to contribute to goapisuit, feel free to open a pull request or issue on the GitHub repository.

License

This project is licensed under the MIT License.

Credits

GoFiberA web framework that brings lightning-fast performance to your Golang applications. GORM A powerful ORM library for Golang, simplifying database handling and migrations.

Documentation

Index

Constants

View Source
const Version = "v1.0.2"

Variables

This section is empty.

Functions

func LoadTmpModel

func LoadTmpModel() (arr []string, err error)

Types

type Config added in v1.0.2

type Config struct {
	AppName string `env:"APP_NAME"`
	AppHost string `env:"APP_HOST"`
	AppPort string `env:"APP_PORT"`

	ApiPrefix    string `env:"API_PREFIX"`
	ApiLimitPage int    `env:"API_LIMIT_PAGE"`
	DbConnection string `env:"DB_CONNECTION"`
}

func LoadEnv added in v0.1.1

func LoadEnv() Config

type Suit

type Suit struct {
	ProjectName    string
	DB             *gorm.DB
	LimitPage      int
	RequireJwtAuth func(*fiber.Ctx) error
	Fiber          *fiber.App
	Routes         *interface{}
	Config         Config
}

func New

func New(project_name string, fiberConfig ...fiber.Config) (suit *Suit, err error)

func (*Suit) GroupScan added in v1.0.2

func (s *Suit) GroupScan() (groups []string, err error)

func (*Suit) Run

func (s *Suit) Run()

func (*Suit) SetupGroups added in v1.0.2

func (s *Suit) SetupGroups(api_prefix string, r interface{}, middleware ...fiber.Handler) (err error)

func (*Suit) SetupRoutes added in v1.0.2

func (s *Suit) SetupRoutes(r interface{})

Directories

Path Synopsis
cmd
heykrit command
internal
pkg

Jump to

Keyboard shortcuts

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