Check the API documentation for more information (for now this page is hosted locally, so please run the project before accessing the documentation).
- Go (version 1.22+)
- Air
- docker compose
- migrate
- Just
docker compose up -d
just migrate
just dev
- Make sure that you have
air
go install github.com/air-verse/air@latest
- Clone the repository
- Provide the following environment variables in the
.env
file
# for now none needed
PORT="4000"
PG_USER="postgres"
PG_PASSWORD="postgres"
PG_PORT="5432"
PG_HOST="0.0.0.0"
PG_DATABASE="gists"
PUBLIC_URL="http://localhost:4000"
FRONTEND_URL="http://localhost:3000"
GOOGLE_KEY="<REDACTED>"
GOOGLE_SECRET="<REDACTED>"
GITHUB_KEY="<REDACTED>"
GITHUB_SECRET="<REDACTED>"
MAIL_SMTP="<REDACTED>"
MAIL_PASSWORD="<REDACTED>"
SMTP_PORT="<REDACTED>"
SMTP_HOST="<REDACTED>"
APP_KEY="<REDACTED>"
ENV="development"
- Run the server in development mode
just dev
# or
air
All the configuration is done through env variables :
PORT
: the port on which your web server runsPG_USER
: the postgres userPG_PASSWORD
: the postgres passwordPG_PORT
: the postgres portPG_HOST
: the postgres hostPG_DATABASE
: the postgres databasePUBLIC_URL
: The URL on which your application is available. If you use a reverse proxy to make your app available, you need to provide its URL thanks to this variable. It is mainly use as the redirection URL used during the authentication flow.FRONTEND_URL
: The URL on which your frontend is available. It is mainly use to set the cookie after the authentication flowGOOGLE_KEY
: your google client key for OAUTH2GOOGLE_SECRET
: your google client secret for OAUTH2GITHUB_KEY
: your github client key for OAUTH2GITHUB_SECRET
: your github client secret for OAUTH2MAIL_SMTP
: your smtp serverMAIL_PASSWORD
: your smtp passwordSMTP_PORT
: your smtp portSMTP_HOST
: your smtp hostAPP_KEY
: your app key, which is a random string that is used to encrypt access tokensENV
: the environment in which the app is running (development, production)
To run tests, execute:
just test <your-test-name>
# or to run all tests
just test-all
For migrations we use migrate.
To create a migration run the following command :
migrate create -ext=sql -dir=migrations -seq init
To run the existing migrations locally :
just migrate
# or
migrate -path=migrations -database "postgresql://postgres:[email protected]:5432/gists?sslmode=disable" -verbose up
To rollback a migration :
migrate -path=migrations -database "postgresql://postgres:postgres@localhost:5432/gists?sslmode=disable" -verbose down 1