recipes/todo-app-with-auth-gorm

Todo App + Auth + GORM

A Todo application with authentication using GORM.

Todo App with Auth using GORM

Github StackBlitz

This project demonstrates a Todo application with authentication using GORM.

Prerequisites

Ensure you have the following installed and available in your GOPATH:

  • Golang
  • Air for hot reloading
  • Godotenv for loading .env file

Installation

  1. Clone the repository:

    git clone https://github.com/gofiber/recipes.git
    cd recipes/todo-app-with-auth-gorm
  2. Install dependencies:

    go get
  3. Create the environment file and add a secret for signing the JWTs. air loads .env, and the application refuses to start without TOKEN_KEY:

    cp .env.example .env
    echo "TOKEN_KEY=$(openssl rand -hex 32)" >> .env

Running the Application

  1. Start the application:
    air

Environment Variables

VariableDescriptionDefault
PORTServer listening port5000
DBName of the SQLite database filegotodo.db
TOKEN_KEYSecret used to sign the JWTs. Generate a random one with openssl rand -hex 32required
TOKEN_EXPToken lifetime, a time.ParseDuration string10h