Skip to content

lucasmonstrox/go-clean-architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📝 Description

A REST API boilerplate

🎉 Features

  • TODOS: CRUD around TODOS

🧰 Installation

Prerequisites

  • go1.16
  • Docker

Install go packages and dependencies before continue

go install

Setting up PostgreSQL database

  • This is will make a new PostgreSQL running in the standard port 5432
  • Please shutdown any previous conflicting PostgreSQL instances before starting this
docker-compose up -d

Check the database is up

docker logs -f content_pg

Check that you can log into a database with psql

docker exec -it content_pg psql -U content_pg_user content_pg_db

View tables

\dt

⌨ Development

⚙ Running the app

go run main.go

# or air with live reload
air

🎮 Playground

After the application starts, go to http://localhost:$PORT/swagger/index.html to access swagger playground

Observartion: You must change $PORT for the port to be used in your environment

🧪 Running tests

Creating tests database Only integration tests are supported. Backend is spun up on a special database

Tests use their own database. To create it:

docker exec -it content_pg psql -U content_pg_user -c "create database content_pg_db_test" content_pg_db

Note that in backend/config/typeorm.config.ts the content_db_test database is configured to synchronize TypeORM migrations automatically, unlike the development database.

# unit tests
go test

📦 Building

Before building application to production, make sure environment variables are applied correctly

Building for production

go build

✅ TODO

  • Add environment variables
  • Add migrations to mongo-db-driver
  • Add optional parameters to swagger
  • Add bearer auth to swagger
  • Add unit tests
  • Add integration tests
  • Add e2e tests
  • Add log system
  • Add health check

Observation: Some TODOS are spread across the code and need to be fixed ASAP

🛠 Built with

  • go - Go is an open source programming language supported by Google

👷 Authors

See also the list of contributors who participated in this project

📝 License

Copyright © 2020 Lucas Silva
This project is MIT licensed