This is a starter project that uses Go as a companion server for Hasura.
For a node.js based version see : https://github.com/aaronblondeau/hasura-base
Authentication is handled by Hasura and JWTs.
- Install dependencies
go get
Also install the hasura cli : https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/
-
Copy .env.example to .env and update values (note "TODO" values). The S3 secret and key will be updated in step 4 below.
-
Start the docker containers
Before starting the containers, switch the postgres image to something like "postgis/postgis:15-3.3" in docker-compose.yml if you need PostGIS support.
docker compose up -d
-
Use the minio UI (http://localhost:9090/) to create a 'user-public' bucket as well as to create an api access key and secret. Update S3_ACCESS_KEY and S3_SECRET_KEY in .env file.
-
Run hasura migrations and apply metadata
set HASURA_GRAPHQL_ADMIN_SECRET "mydevsecret"export HASURA_GRAPHQL_ADMIN_SECRET=mydevsecrethasura migrate apply --project ./hasura
hasura metadata apply --project ./hasura
- Update prisma:
go run github.com/steebchen/prisma-client-go db pull
go run github.com/steebchen/prisma-client-go generate
- Start the hasura console
set HASURA_GRAPHQL_ADMIN_SECRET "mydevsecret"
hasura console --project ./hasuraexport HASURA_GRAPHQL_ADMIN_SECRET=mydevsecret
hasura console --project ./hasura- Start the golang server
go run main.go
- Use the hasura console to create additonal tables, actions, events, relationships, and permissions.
Other admin tools are available at (see .env file for passwords): Minio UI : http://localhost:9090/
- When done, stop the docker containers
docker compose down
Emails templates are managed with maizzle.
To develop email templates make sure you have Node.js installed and then:
cd emails
npm install
npm run dev
Once the dev server has started, go to http://localhost:3050/. Updates to templates will live reload!
To build email templates
cd emails
npm run build
Note that email templates are embedded in the go executable so they must be generated before building or running "go run main.go".
https://goprisma.org/docs/getting-started/quickstart
How to set go prisma db conn string from env var? Update env vars (crew specific ones added, search for os.Getenv)