Kei-K23 / go-otp

Go Todo application with user registration with JWT and SMS OTP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go TODO + OTP

Go Todo application with user registration with JWT and SMS OTP.

Teach stack

  • Go + Gin
  • Templ
  • HTMX
  • MySQL
  • more go tools...

Prerequisites

  • Go programming language installed on your system
  • MySQL or another compatible database installed and running
  • .env file containing environment variables (e.g., database connection details, server port)

Installation

  1. Clone this repository to your local machine:
git clone https://github.com/Kei-K23/go-otp.git
  1. Navigate to the project directory:
cd go-otp
  1. Create a .env file in the project root and add the following environment variables:
JWT_SECRET_KEY=<YOUR_JWT_SECRET_KEY>
DB_CONNECTION=<YOUR_DB_CONNECTION>
SENDER=<YOUR_TWILIO_SENDER_NUMBER>
TWILIO_AUTH_TOKEN=<YOUR_TWILIO_AUTH_TOKEN>
TWILIO_ACCOUNT_SID=<YOUR_TWILIO_ACCOUNT_SID>

Usage

  1. Install dependencies:
go mod tidy
  1. Run migration
make migration
  1. Push database table
make migrate-up
  1. Run server
make run

This will serve the server at http://localhost:8080

  1. Access the API endpoints using tools like cURL or Postman.

API endpoints

All endpoints are available under http://localhost:4000/api/v1. Make sure prefix with your localhost with /api/v1.

Authentication

  • POST /register: Register page
  • POST /login: Login page
  • POST /verify: Verify page

Below defined endpoints are protected with JWT authentication. Make sure valid JWT token exist in bearer authentication header

Users

  • GET /users: User page

About

Go Todo application with user registration with JWT and SMS OTP.


Languages

Language:Go 98.6%Language:Makefile 1.4%