Categorygithub.com/orlandorode97/mailx-google-service
repositorypackage
0.0.0-20220402075604-2eb00bf65d7b
Repository: https://github.com/orlandorode97/mailx-google-service.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

mailx-google-service

mailx-google-service is an open-source microservice that consumes the Gmail API for an open-souce email client Mailx

mailx-google-service tools

mailx-google-service uses multiple libraries and tools to work such as:

  • gorila mux for a multiplexer router.
  • go-kit standard library for microservices architecture.
  • sqlx an extension for database/sqlgolang package.
  • goose for incremental or decremental migrations.
  • pq driver for a postgres database.
  • oauth2 for authorization.

Getting started

To get started with mailx-google-service is important to have the following tools installed in your machine:

  • go v1.17+ (primary programming language)
  • Docker
  • goose (migration tool)

Clone the project in your desired location such as on $GOPATH:

git clone https://github.com/orlandorode97/mailx-google-service.git

mailx-google-services requires a .env at the root of the project with the following variables:

POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=mailx-google-service-db-1
POSTGRES_HOST_GOOSE=localhost
POSTGRES_PORT=5432
POSTGRES_DB_NAME=postgres
POSTGRES_SSL_MODE=disable
POSTGRES_DB_SCHEMA=public


GOOGLE_REDIRECT_URL=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

After setting up the .env at the root the project run:

make build-run

The previous command builds a mailx-google-service container along with another container for a postgres database. Check the Makefile for more available commands.

Migrations

To perform migrations it's required to have installed goose in your machine. Check tools section. To create a migration file run the following command:

goose create migration_file_name

The previous command will generate a go file where the needed sql statements will be placed. This migration has the following format yyyymmddhhmmss_migration_name.go and is created at the root of the project, you should move the migration file into the migrations folder.

When the container mailx-google-service is up and running run the follwing command to run a migration:

make goose-up

Your terminal should print something like:

Building goose binary --->
go build -o . ./cmd/goose
Goose binary built
Up migrations
./goose up
<nil>
2022/01/25 00:48:59 OK    20220124004601_google_users_table.go
2022/01/25 00:48:59 OK    20220124234200_google_auth_users_table.go
2022/01/25 00:48:59 OK    20220124235821_auth_users_relation.go
2022/01/25 00:48:59 goose: no migrations to run. current version: 20220124235821
Migrations up successfully

TODO

A lot of things 😳