Skip to content

davidphex/event-go-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event Management API

A RESTful API built with Go and Gin framework for managing events and attendees.

Features

  • User Authentication: JWT-based authentication system with user registration and login
  • Event Management: Full CRUD operations for events with owner-based permissions
  • Attendee Management: Add, remove, and list attendees for events
  • Database Integration: SQLite database with migration support
  • API Documentation: Swagger/OpenAPI documentation for all endpoints
  • Test Coverage: Comprehensive test suite

Project Structure

├── cmd/
│   ├── api/              # API handlers and server setup
│   │   ├── auth.go       # Authentication handlers
│   │   ├── events.go     # Event and attendee handlers
│   │   ├── main.go       # Application entry point
│   │   ├── routes.go     # Route definitions
│   │   └── server.go     # Server configuration
│   └── migrate/          # Database migrations
├── internal/
│   ├── database/         # Database models and operations
│   └── env/              # Environment configuration
├── tests/                # Test suite
└── docs/                 # Swagger documentation

Development Commands

Running the Application

make dev          # Run tests then start development server
make run          # Run tests then start server
make build        # Run tests then build application

Testing

make test         # Run all tests
make test-coverage # Run tests with coverage report
make test-unit    # Run unit tests only

Code Quality

make format       # Format code
make lint         # Lint code
make swagger      # Generate Swagger documentation

Database

make migrate-up   # Run database migrations
make clean        # Clean build artifacts and database

Authentication

The API uses JWT (JSON Web Tokens) for authentication. After successful login, include the token in the Authorization header:

Authorization: Bearer <your_jwt_token>

Protected endpoints require valid authentication and will return 401 Unauthorized if the token is missing or invalid.

Getting Started

  1. Clone the repository
  2. Install dependencies: make deps
  3. Run migrations: make migrate-up
  4. Start the development server: make dev
  5. View API documentation at /swagger/index.html

The API will be available at http://localhost:4000 by default (you can edit the port & the JWT secret via the PORT and JWT_SECRET environment variables).

Testing

The project includes comprehensive tests covering database models and business logic. Tests use an in-memory SQLite database for isolation and speed.

Run the test suite:

make test

Generate coverage report:

make test-coverage

About

Events REST API written in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published