Skip to content

YiChengHsu/meme-coin-api-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meme Coin API Server

A Go-based API server for the Meme Coin project.

Project Structure

.
├── Makefile            # Make commands for development
├── cmd/
   └── api/           # Main application entry point
       ├── config/    # Configuration handling
       └── main.go    # Main application file
├── internal/
   └── api/          # Internal API packages
       ├── controller/  # HTTP handlers
       ├── dao/        # Data Access Objects
       ├── migrations/ # Database migrations
       ├── model/     # Data models
       └── service/   # Business logic
├── pkg/              # Shared packages
   ├── apierror/    # API error handling
   ├── database/    # Database related packages
   ├── log/        # Logging utilities
   └── utils/      # Common utilities
└── dev-support/
    ├── docker/          # Dockerfile definitions
    └── docker-compose/  # Docker compose files and environment configs

Getting Started

Prerequisites

  • Go 1.21 or higher
  • Docker and Docker Compose
  • Make (optional)

Running Locally

  1. Clone the repository:
git clone https://github.com/YiChengHsu/meme-coin-api-server.git
cd meme-coin-api-server
  1. Set up environment file:
# Create env file from template
cp dev-support/docker-compose/env/template.env dev-support/docker-compose/env/.env

# Edit the env file according to your needs
vim dev-support/docker-compose/env/.env
  1. Run with Docker Compose :
# Using Makefile (recommended)
make docker-compose-up

# Or using Docker command directly
docker compose -f dev-support/docker-compose/docker-compose.yml up -d

The API server will be available at http://localhost:8080

Configuration

The application can be configured using environment variables:

Server Configuration

  • SERVER_TIME_ZONE: Timezone setting (e.g., "Asia/Taipei")
  • SERVER_ALLOW_ORIGINS: Allowed CORS origins
  • SERVER_HTTP_LISTEN_ADDR: HTTP listen address
  • SERVER_HTTP_LISTEN_PORT: HTTP listen port
  • SERVER_TRUST_PROXIES: Trusted proxy CIDR ranges

Database Configuration

  • DATABASE_HOST: Database host
  • DATABASE_PORT: Database port
  • DATABASE_USER: Database user
  • DATABASE_PASSWORD: Database password
  • DATABASE_DB_NAME: Database name
  • DATABASE_SSLMODE: SSL mode
  • DATABASE_MIGRATION_URL: Migration files location

Running Tests

You can run tests either locally or in Docker:

# Run tests locally

# Using Makefile (recommended)
make docker-compose-up

# Run directly
./internal/api/controller/test.sh

Note:

  • The test environment variables are configured in internal/api/controller/test.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published