Giter Club home page Giter Club logo

gin-n-juice's Introduction

Gin-N-Juice Framework

Gin-N-Juice is a Go JSON API framework that is built on Gin, Gorm and Goose.

Current Features

  • Uses Gorm as an ORM
  • Database migrations via Goose
  • Simple routing via Gin
  • Simple Auth (login,register,email verification,forgot password and reset password)
  • File watcher to auto reboot server during development

Requirements

  • The only mail provider that currently works is Mailgun.
  • Go version 1.18 or later

Setup

Create a .env in the root directory of the project. The required environment variables are:

ENCRYPT_KEY=[randomstring]
MAILGUN_DOMAIN=[get from mailgun]
MAILGUN_PRIVATE_KEY=[get from mailgun]
MAILGUN_VALIDATION_KEY=[get from mailgun]
DB_TYPE=[sqlite,postgres or mysql]
DB_CONNECTION_STRING="[connection string for your db, see below]"
PORT=[port to run server on. defaults to port 8080]
SERVER_HOSTNAME=[hostname server will listen for. defaults to 127.0.0.1/localhost]
MODE=[set to "production", otherwise runs in debug mode]
EMAIL_FROM=[default email address to send messages from]
PACKAGE_NAME=[if you change your package name in go.mod update this to match]

Example DB connection string reference:

MySQL: "user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
SQLite: "gorm.db"
PostgreSQL: "host=localhost user=gorm password=gorm dbname=gorm port=5432 sslmode=disable TimeZone=America/New_York"

Add routes to the routes directory and reference them in the routes/router.go.

Commands

  • go run . or go run . serve
    • Runs the webserver
    • Also sets up a watcher and will auto restart webserver when files are changed
  • go run . migrate [status|up|down|create|etc...]
    • Runs goose migrations, see goose's documentation for more details
  • go run . rename [package-name]
    • If you want to change your package name from gin-n-juice to something else. It will update the go.mod and all .go file imports
  • go run . test
    • Run tests on all routes and models
  • go run . seed
    • Run the seeders specified in ./seeders/main.go
  • go run . generator -type [model|resource] -name [ex:user] -fields [name:type,name:type,...]
    • -fields is only used with model type
    • resource creates standard API endpoints for the name (create,update,delete,list,view)
    • use singular names, the name will automatically be pluralized when needed (example: user not users)
    • Example: go run . generator -type model -name book -fields title:string,category_id:uint,pages:uint
      • Creates a single file book.go in the /models directory
    • Example: go run . generator -type resource -name book
      • Creates a new directory /routes/books
      • Creates five files in that directory
        • create.go, delete.go, get.go, list.go, update.go

gin-n-juice's People

Contributors

pitchinnate avatar rohitshelke10 avatar davisthedev avatar barqus 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.