diff --git a/.env.example b/.env.example index b6905fe4..1ba3384b 100644 --- a/.env.example +++ b/.env.example @@ -38,4 +38,5 @@ FINGERPRINT_API_URL=https://api.fpjs.io/ STRING_INTERNAL_ID=00000000-0000-0000-0000-000000000000 STRING_WALLET_ID=00000000-0000-0000-0000-000000000001 STRING_BANK_ID=00000000-0000-0000-0000-000000000002 -STRING_PLACEHOLDER_PLATFORM_ID=00000000-0000-0000-0000-000000000003 \ No newline at end of file +STRING_PLACEHOLDER_PLATFORM_ID=00000000-0000-0000-0000-000000000003 +SERVICE_NAME=string_api \ No newline at end of file diff --git a/README.md b/README.md index 3929e2ce..19f0392b 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -### For Live Reloading: ### -1. install [Air|https://github.com/cosmtrek/air]: `go install github.com/cosmtrek/air@latest` -2. run `air` -3. if you get `zsh: command not found: air` you need to add to PATH: `PATH=$PATH:$(go env GOPATH)/bin` +### To run the APIS: ### +1. Ensure you have the infra repo where the docker compose file is now located +2. run `docker compose -f ../infra/local/docker-compose.yml up` +3. You can also run with the -d flag to keep the process in the background, ie `docker compose -f -d ../infra/local/docker-compose.yml up` -### For migrations: ### -1. install [Goose|https://pressly.github.io/] `brew install goose` -2. Note, this binary is separate from the go package. -3. `goose postgres "host=localhost dbname=string_db user=string_db password=string_password sslmode=disable" down-to 0` +### To get a live terminal output from any repository being run by the infra docker compose: ### +1. Run `docker logs [docker container name] -f` +2. ie `docker logs platform-admin-api -f` +3. You can get the container names using `docker ps` +4. If you don't want the output in real time, you can omit the `-f` flag -### Postgres & Redis - Docker Compose: ***local dev only*** ### -1. To build and start the docker containers for the first time: `docker-compose up --build` -2. To shutdown the docker containers press `ctl + c` +### For migrations: ### +1. This is now handled by the docker compose file ### Docker Issues? 1. If docker is giving you an error when you try to `docker-compose up --build` try the following commands in order: @@ -25,8 +25,10 @@ run `go install` to get dependencies installed ### For local testing: ### run `go test` +or if you want to run a specific test, use `go test -run [TestName] [./path/to/dir] -v -count 1` +ie `go test -run TestGetSwapPayload ./pkg/service -v -count 1` ### Unit21: ### This is a 3rd party service that offers the ability to evaluate risk at a transaction level and identify fraud. A client file exists to connect to their API. Documentation is here: https://docs.unit21.ai/reference/entities-api You can create a test API key on the Unit21 dashboard. You will need to be setup as an Admin. Here are the instructions: https://docs.unit21.ai/reference/generate-api-keys -When setting up the production env variables, their URL will be: https://api.unit21.com/v1 +When setting up the production env variables, their URL will be: https://api.unit21.com/v1 \ No newline at end of file diff --git a/dev.Dockerfile b/dev.Dockerfile index 87be470f..77154435 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -12,8 +12,7 @@ ADD go.mod go.sum /string_api/ RUN go mod download # install the air tool -RUN curl -fLo install.sh https://raw.githubusercontent.com/cosmtrek/air/master/install.sh \ - && chmod +x install.sh && sh install.sh && cp ./bin/air /bin/air +RUN go install github.com/cosmtrek/air@latest # install goose for db migrations RUN go install github.com/pressly/goose/v3/cmd/goose@latest diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 7108b7bc..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,51 +0,0 @@ -version: '3.8' -services: - string-api: - build: - context: . - dockerfile: dev.Dockerfile - container_name: string-api - ports: - - 5555:5555 - depends_on: - redis: - condition: service_started - db: - condition: service_healthy - volumes: - - ./:/string_api - db: - image: postgres:14.1-alpine - restart: always - environment: - - POSTGRES_USER=string_db - - POSTGRES_PASSWORD=string_password - ports: - - '5432:5432' - volumes: - - db:/var/lib/postgresql/data - healthcheck: - test: ["CMD-SHELL", "pg_isready -U string_db"] - interval: 5s - timeout: 5s - retries: 5 - redis: - image: redis:7.0-alpine - restart: always - ports: - - '6379:6379' - command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81 - ## We want the Redis data not to persist. - ## Commenting out the lines below is equivalent to run the command FLUSHALL after each restart - ## Uncomment the following lines to persist data - # volumes: - # - redis:/data - -volumes: - db: - driver: local - ## We want the Redis data not to persist. - ## Commenting out the lines below is equivalent to run the command FLUSHALL after each restart - ## Uncomment the following lines to persist data - # redis: - # driver: local diff --git a/migrations/0005_user-to-platform_contact-to-platform_device-to-instrument_platform.sql b/migrations/0005_user-to-platform_contact-to-platform_device-to-instrument_platform.sql index 0568dda5..f2220fdd 100644 --- a/migrations/0005_user-to-platform_contact-to-platform_device-to-instrument_platform.sql +++ b/migrations/0005_user-to-platform_contact-to-platform_device-to-instrument_platform.sql @@ -41,7 +41,7 @@ ALTER TABLE platform DROP COLUMN IF EXISTS authentication, ADD COLUMN activated_at TIMESTAMP WITH TIME ZONE DEFAULT NULL, -- for activating prod users ADD COLUMN name TEXT NOT NULL, - ADD COLUMN description TEXT NOT NULL, + ADD COLUMN description TEXT DEFAULT '', ADD COLUMN domains TEXT[] DEFAULT NULL, -- define which domains can make calls to API (web-to-API) ADD COLUMN ip_addresses TEXT[] DEFAULT NULL; -- define which API ips can make calls (API-to-API) diff --git a/migrations/0006_platform-member_member-to-platform_member-role_member-to-role_member-invite_apikey.sql b/migrations/0006_platform-member_member-to-platform_member-role_member-to-role_member-invite_apikey.sql index 43f665d9..d0f106a8 100644 --- a/migrations/0006_platform-member_member-to-platform_member-role_member-to-role_member-invite_apikey.sql +++ b/migrations/0006_platform-member_member-to-platform_member-role_member-to-role_member-invite_apikey.sql @@ -9,7 +9,7 @@ CREATE TABLE platform_member ( updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, deactivated_at TIMESTAMP WITH TIME ZONE DEFAULT NULL, email TEXT NOT NULL, - password TEXT NOT NULL -- how do we maintain this? + password TEXT DEFAULT '' -- how do we maintain this? ); -------------------------------------------------------------------------