whistleblower

command module
v0.0.0-...-2b7dfc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2020 License: Unlicense Imports: 12 Imported by: 0

README

Whistleblower

Go Docker Postgres

WhistleNews is a news portal for whistleblowers. Registered authors would be able to post articles without the need to reveal their identity publically.

Architecture

This project try to implement Clean Architecture and the Apps architecture can use Kong for API Gateway and can use Kong Authentication for authentication mechanism. Right now this service only use server key to access the endpoints.

Event Driven architecture use message broker (RabbitMQ, Kafka, NATS, etc).

Libraries

Use Go Module for install all dependencies required this application.

How To Run and Deploy

Before run this service. Make sure all requirements dependencies has been installed likes Golang, Docker, and Postgres

Local

Use command go go run main.go in root folder for run this application.

  • go run main.go migrate:run Command to run database migration
  • go run main.go migrate:rollback Command to rollback database migration
  • go run main.go migrate:create Command to create database migration file
Docker

whistleblower uses docker multi stages build, minimal docker version is 17.05. If docker already installed use command.

This command will build the images.

docker build -f Dockerfile -t $(IMAGE):$(VERSION) .

Run this command for database migration

docker-compose run --rm $(NAME) migrate:run

To run service use this command

docker run --name whistleblower -d -e ADDRESS=:8080 -e <environment> $(IMAGE):$(VERSION)
Shell Script

Make sure docker-compose already installed. to run this script.

Use this command for the first time. this script will run docker compose and run the database migration.

./start.sh run

Use this command to run application without database migration. Need to run ./start.sh run before use this command

./start.sh up

Test

For run unit test, from root project you can go to folder or package and execute command, this project have two kinds of test, Integration Test and Unit Test.

go test -v -cover -coverprofile=coverage.out -covermode=set
go tool cover -html=coverage.out

go tool will generate GUI for test coverage. Available package or folder can be tested.

  • Integration Test
    • /infrastructure/web/handler
    • /article
    • /viewer
  • Unit Test
    • /article/handler/http
    • /viewer/handler/http

API Documentation

This service documentation uses Run in Postman.

Environment Variables

  • SERVER_PORT - Address application is used default is :8080
  • LOG_FORMAT - Format specific for log, default value is text
    • text - Log format will become standard text output, this used for development
    • json - Log format will become JSON format, usually used for production
  • LOG_LEVEL - Log level default is debug
  • POSTGRES_ADDRESS - Database hostname
  • POSTGRES_DATABASE - Database name
  • POSTGRES_USERNAME - Database username
  • POSTGRES_PASSWORD - Database Password
  • POSTGRES_LOG_ENABLED - Database log enabled, value true or false
  • POSTGRES_MAX_OPEN_CONN - Database max open connection
  • POSTGRES_MAX_IDLE_CONN - Database max idle connection

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
infrastructure
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL