Categorygithub.com/anonychun/go-blog-api
module
0.0.0-20221206084352-339351590a65
Repository: https://github.com/anonychun/go-blog-api.git
Documentation: pkg.go.dev

# README

Go Blog API

Real-world examples implementing back-end services for blog application using Go programming language to build RESTful API, all routes and API documentation can be found at {{base_url}}/swagger/index.html

Architecture

This project using Clean Architecture with 4 domain layers:

  • Model
  • Repository
  • Service
  • Handler

Features

  • API Documentation Swagger (auto generate)
  • Command line options
  • Authentication Json Web Token
  • CRUD operations Postgres (raw sql)
  • Caching Redis
  • Pagination, URL query search, etc
  • Environment variables config
  • Database Migrations, Rollbacks, Steps, Drop, etc
  • Validation data request
  • Middlewares CORS, Rate Limit, Logger, Recover, Custom, etc
  • Graceful shutdown
  • Many more...

System Requirements

  • Golang
  • Docker
  • Postgres (included in docker compose)
  • Redis (included in docker compose)

Running

Setting up all containers

$ make compose.up

Applying all up migrations and start the server

$ make launch

Destroy

Applying all down migrations

$ make rollbacks

Destroy running containers

$ make compose.down

Delete all volumes that doesn't used

$ docker volume prune

Environment Variables

KeyTypeValue (Example)
APP_PORTint1401
HTTP_RATE_LIMIT_REQUESTint100
HTTP_RATE_LIMIT_TIMEduration1s
JWT_SECRET_KEYstringsecret
JWT_TTLduration48h
PAGINATION_LIMITint100
POSTGRES_USERstringadmin
POSTGRES_PASSWORDstringsecret
POSTGRES_HOSTstringlocalhost
POSTGRES_PORTint3306
POSTGRES_DATABASEstringblog
POSTGRES_MAX_IDLE_CONNSint5
POSTGRES_MAX_OPEN_CONNSint10
POSTGRES_CONN_MAX_LIFETIMEduration30m
REDIS_PASSWORDstringsecret
REDIS_HOSTstringlocalhost
REDIS_PORTint6379
REDIS_DATABASEint0
REDIS_POOL_SIZEint10
REDIS_TTLduration1h

# Packages

No description provided by the author
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag.