From 39d60821a1a0a34390de71847523602186d4c3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wysoki=C5=84ski?= Date: Wed, 7 Dec 2022 06:44:58 +0100 Subject: [PATCH] chore: add README.md --- README.md | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 95fe6c0..a4e479f 100644 --- a/README.md +++ b/README.md @@ -32,26 +32,40 @@ skaffold run --port-forward=true --tail=true skaffold delete ``` +#### Run unit tests + +At least one of the following is required to run unit tests: +- Docker ([dockertest](https://github.com/ory/dockertest) will spin up a database) +- Postgres database + +```shell +# Docker +go test -v ./... + +# Postgres database +TESTS_DB_DSN=postgres://sessions:sessions_pass@127.0.0.1/sessions go test -v ./... +``` + ## Configuration options Configuration options can be specified via environment variables. -| Env variable | Default | Description | -|--------------------------------|-----------------------|--------------------------------------------------------------------------------------------------------------------| -| ``APP_MODE`` | ``development`` | Whether to use development or production settings | -| ``DB_DSN`` | | Syntax: ``postgres://user:password@host:5432/db?sslmode=disable``. Only Postgres is supported. | -| ``DB_MAX_OPEN_CONNECTIONS`` | ``5`` | The maximum number of open connections to the database (https://pkg.go.dev/database/sql#DB.SetMaxOpenConns) | -| ``DB_MAX_IDLE_CONNECTIONS`` | ``2`` | The maximum number of connections in the idle connection pool (https://pkg.go.dev/database/sql#DB.SetMaxIdleConns) | -| ``DB_CONNECTION_MAX_LIFETIME`` | ``3m`` | The maximum amount of time a connection may be reused (https://pkg.go.dev/database/sql#DB.SetConnMaxLifetime) | -| ``API_SWAGGER_ENABLED`` | ``false`` | Enable/disable Swagger | -| ``API_SWAGGER_HOST`` | | | -| ``API_SWAGGER_SCHEMES`` | ``http,https`` | | -| ``API_CORS_ENABLED`` | ``false`` | Enable/disable cors headers | -| ``API_CORS_ALLOWED_ORIGINS`` | | List of requesting domains that are allowed | -| ``API_CORS_ALLOW_CREDENTIALS`` | ``false`` | Allow/forbid requests with credentials | -| ``API_CORS_ALLOWED_METHODS`` | ``HEAD,GET,POST,PUT`` | List of allowed methods | -| ``API_CORS_MAX_AGE`` | ``300`` | Max time to cache response (in seconds) | -| | | | +| Env variable | Default | Description | +|--------------------------------|-----------------------|----------------------------------------------------------------------------------------------------------------| +| ``APP_MODE`` | ``development`` | Whether to use development or production settings | +| ``DB_DSN`` | | **Required.** Syntax: ``postgres://user:password@host:5432/db?sslmode=disable``. Only Postgres is supported. | +| ``DB_MAX_OPEN_CONNECTIONS`` | ``5`` | Maximum number of open connections to the database (https://pkg.go.dev/database/sql#DB.SetMaxOpenConns) | +| ``DB_MAX_IDLE_CONNECTIONS`` | ``2`` | Maximum number of connections in the idle connection pool (https://pkg.go.dev/database/sql#DB.SetMaxIdleConns) | +| ``DB_CONNECTION_MAX_LIFETIME`` | ``3m`` | Maximum amount of time a connection may be reused (https://pkg.go.dev/database/sql#DB.SetConnMaxLifetime) | +| ``API_SWAGGER_ENABLED`` | ``false`` | Enables the API documentation endpoints (e.g. ``/api/v1/swagger/index.html``, ``/api/v1/swagger/doc.json``) | +| ``API_SWAGGER_HOST`` | | Host (name or ip) serving the API (e.g. localhost:8080) | +| ``API_SWAGGER_SCHEMES`` | ``http,https`` | Comma-separated list of protocols | +| ``API_CORS_ENABLED`` | ``false`` | Enables cors headers | +| ``API_CORS_ALLOWED_ORIGINS`` | | Comma-separated list of allowed domains | +| ``API_CORS_ALLOW_CREDENTIALS`` | ``false`` | Whether requests with credentials are allowed | +| ``API_CORS_ALLOWED_METHODS`` | ``HEAD,GET,POST,PUT`` | Comma-separated list of allowed methods | +| ``API_CORS_MAX_AGE`` | ``300`` | Max time to cache response (seconds) | +| | | | ## License