Skip to content

SoufianeELAMMARI/GoLang-API-Postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task API - Production Ready Go Backend

Setup

  1. Install dependencies:
go mod download
  1. Start PostgreSQL:
docker run -d -p 5432:5432 \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=admin \
  -e POSTGRES_DB=postgres \
  postgres:15-alpine
  1. Run the application:
go run cmd/api/main.go

API Endpoints

  • GET /health - Health check
  • GET /tasks - Get all tasks
  • POST /tasks - Create new task
  • POST /tasks/update - Update task
  • POST /tasks/delete - Delete task

Docker Build

docker build -t task-api .
docker run -p 8080:8080 --env-file .env task-api

Project Structure

myapp/
├── cmd/api/              # Application entry point
├── internal/             # Private application code
│   ├── handlers/         # HTTP handlers
│   ├── middleware/       # HTTP middleware
│   ├── models/          # Data models
│   ├── repository/      # Database layer
│   └── service/         # Business logic
├── pkg/                 # Public libraries
│   ├── database/        # Database utilities
│   └── response/        # HTTP response helpers
└── config/              # Configuration

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published