Skip to content

Latest commit

 

History

History
85 lines (58 loc) · 2.3 KB

README.md

File metadata and controls

85 lines (58 loc) · 2.3 KB

phinvads-go

PHIN VADS written in Go. Load phinvads.dump into a PostgreSQL database using pg_restore, run the app with air, and go!

Dev setup

Clone the repo:

git clone https://github.com/skylight-hq/phinvads-go.git
cd phinvads-go

direnv setup and configuration

  1. Install direnv (brew install direnv)
  2. Add a hook for your shell
  3. Restart your terminal
  4. Run direnv allow in the project directory

Database setup

Running Postgres in Docker

Download and install Docker if you don't already have it installed.

  1. Place phinvads.dump into the top level of your project directory (/phinvads-go)
  2. Navigate to the project directory and start your PostgreSQL database with make start
  3. Run make refresh to create the phinvads database and load in the data

When you want to shut down your database environment, run make stop.

Running Postgres locally

  1. Install and run PostgreSQL

  2. Create an empty database:

    psql -c 'CREATE DATABASE phinvads'
  3. Load the database dump file:

    pg_restore -d phinvads --no-owner --role=$(whoami) phinvads.dump

Application setup

  1. Install Go

  2. Install air:

    go install github.com/air-verse/air@latest
  3. Install templ

    go install github.com/a-h/templ/cmd/templ@latest
  4. Install mkcert

  5. Create your own self-signed certs for local development:

    cd tls
    mkcert -install
    mkcert localhost
    cd ..
  6. Run the app! If you are only working on backend code, you can just run a simple live reload with air:

    air
  7. Air will also work for the frontend, but you will have to refresh your browser every time you make a change. To get automatic browser reloads, run the app this way:

    templ generate --watch --proxy="http://localhost:4000"
    # Then, in a separate terminal window, run air:
    air -c .air-with-proxy.toml