greenlight

module
v0.0.0-...-55712e9 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT

README

greenlight

Greenlight is a project covered in the book Let's Go Further by Alex Edwards.

I've also made a series of blog posts as I follow along this book, check it out at blog.amyndang.me

Setup

Pre-reqs

Have these programs installed on your machine:

Environment Variables

Create a environment variable with:

export GREENLIGHT_DB_DSN="postgres://greenlight:password@localhost/greenlight"

OR create a .envrc file. Use .envrc_example as a reference.

Build & Run

Build API with:

make db/migrations/new name=db_name
make db/migration/up
make build/api

This will create a executable file called api in greenlight/bin/linux_amd64

Run the executable with:

make run/api

Deployment

After setting up server, remember to grab IP Address of server and replace it in ./remote/production/Caddyfile and in Makefile

// ./remote/production/Caddyfile
http://161.35.71.158

// File: ./Makefile
production_host_ip = '161.35.71.158'
make production/deploy/api

Listening to Logs On Production

sudo journalctl -u api

Useful Development Commands

Psql Migration Commands
migrate -path=./migrations -database=$GREENLIGHT_DB_DSN up

TODO

  • remove SMTP credentials hardcode from main.go and set as ENV variable

Directories

Path Synopsis
cmd
api
internal
vcs

Jump to

Keyboard shortcuts

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