Giter VIP home page Giter VIP logo

go-blog-api's Introduction

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 MySQL / MariaDB (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
  • MySQL / MariaDB (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

Key Type Value (Example)
APP_PORT int 1401
HTTP_RATE_LIMIT_REQUEST int 100
HTTP_RATE_LIMIT_TIME duration 1s
JWT_SECRET_KEY string secret
JWT_TTL duration 48h
PAGINATION_LIMIT int 100
MYSQL_USER string admin
MYSQL_PASSWORD string secret
MYSQL_HOST string localhost
MYSQL_PORT int 3306
MYSQL_DATABASE string test
MYSQL_MAX_IDLE_CONNS int 5
MYSQL_MAX_OPEN_CONNS int 10
MYSQL_CONN_MAX_LIFETIME duration 30m
REDIS_PASSWORD string secret
REDIS_HOST string localhost
REDIS_PORT int 6379
REDIS_DATABASE int 0
REDIS_POOL_SIZE int 10
REDIS_TTL duration 1h

go-blog-api's People

Contributors

anonychun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.