From 61e55db439a438367176177d943952f66d9616c7 Mon Sep 17 00:00:00 2001 From: tejaskh3 Date: Tue, 6 May 2025 01:18:54 +0530 Subject: [PATCH 1/4] fix: readme --- README.md | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index edad5f9..c2ab371 100644 --- a/README.md +++ b/README.md @@ -30,17 +30,46 @@ You should have some things pre-installed : git clone https://github.com/Real-Dev-Squad/identity-service.git ``` -## Run -### *How to add the service file credentials in the sample-env.json* -- Remove all the spaces such that the whole _json_ that you copied is in a single line -- Replace **\n** with **\\\\n** in your copied json -- Replace **"** with **\\"** in your copied json -### *Firestore setup before running the server locally* -- Create an application on [FireStore](https://firebase.google.com/docs/firestore) and [generate a service file](https://cloud.google.com/iam/docs/creating-managing-service-account-keys). -- Add the service file credentials in the sample-env.json file as a string. -- Rename `sample-env.json` to `env.json` - -### *Executing the script to run the server locally* +# Setting Up Environment for Local Server + +## 1. Firestore Setup +1. Create an application on [Firebase Firestore](https://firebase.google.com/docs/firestore) +2. [Generate a service account key file](https://cloud.google.com/iam/docs/creating-managing-service-account-keys) + +## 2. Environment Configuration +1. Create an `env.json` file by copying the `sample-env.json` template +2. Add your Firestore service credentials to the file + +### Formatting Service Credentials +When adding the service account JSON to your `env.json` file: +- Convert the entire JSON to a single line string +- Escape special characters: + - Replace all newlines (`\n`) with escaped newlines (`\\n`) + - Replace all double quotes (`"`) with escaped double quotes (`\"`) + +### Example +If your service account JSON looks like this: +```json +{ + "type": "service_account", + "project_id": "your-project-id", + "private_key_id": "key-id", + "private_key": "-----BEGIN PRIVATE KEY-----\nkey-content\n-----END PRIVATE KEY-----\n", + "client_email": "email@example.com" +} +``` + +It should be added to `env.json` as: +```json +{ + "FIRESTORE_CREDENTIALS": "{\"type\":\"service_account\",\"project_id\":\"your-project-id\",\"private_key_id\":\"key-id\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\nkey-content\\n-----END PRIVATE KEY-----\\n\",\"client_email\":\"email@example.com\"}" +} +``` + +## 3. Running the Server +After completing the above steps, you can now run the server locally with your configured environment. + +##### *Executing the script to run the server locally* - Windows users need to download & install [Git bash](https://gitforwindows.org/) to execute the scirpt. - Mac/Linux users can run the script in your native terminal. From 030979c5b7db6f7e0a0984024422218fb0b0f4fe Mon Sep 17 00:00:00 2001 From: lakshayman Date: Sat, 31 May 2025 12:33:58 +0530 Subject: [PATCH 2/4] fix: readme --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c2ab371..9206e3c 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,15 @@ You should have some things pre-installed : git clone https://github.com/Real-Dev-Squad/identity-service.git ``` -# Setting Up Environment for Local Server +# Setting Up the Environment for Your Local Server + +## Firestore Setup -## 1. Firestore Setup 1. Create an application on [Firebase Firestore](https://firebase.google.com/docs/firestore) 2. [Generate a service account key file](https://cloud.google.com/iam/docs/creating-managing-service-account-keys) -## 2. Environment Configuration +## Environment Configuration + 1. Create an `env.json` file by copying the `sample-env.json` template 2. Add your Firestore service credentials to the file @@ -67,12 +69,13 @@ It should be added to `env.json` as: ``` ## 3. Running the Server + After completing the above steps, you can now run the server locally with your configured environment. -##### *Executing the script to run the server locally* +### Executing the script to run the server locally -- Windows users need to download & install [Git bash](https://gitforwindows.org/) to execute the scirpt. -- Mac/Linux users can run the script in your native terminal. +- Windows users need to download & install [Git bash](https://gitforwindows.org/) to execute the script. +- Mac/Linux users can run the script in their native terminal. ``` sh scripts/dev.sh From a4c13257e0f451e6d03914bcffce08ac9b02acf2 Mon Sep 17 00:00:00 2001 From: vinit bliro Date: Mon, 9 Jun 2025 00:30:05 +0530 Subject: [PATCH 3/4] fix: update dev.sh to support cross-platform --- scripts/dev.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/dev.sh b/scripts/dev.sh index 3675521..4ae82ee 100644 --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -1,3 +1,9 @@ +if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then + SAM_CMD="sam.cmd" +else + SAM_CMD="sam" +fi + go mod tidy -sam.cmd build -sam.cmd local start-api --env-vars env.json \ No newline at end of file +$SAM_CMD build +$SAM_CMD local start-api --env-vars env.json \ No newline at end of file From 142a194606a170650c9332aa4636d9c3978475fe Mon Sep 17 00:00:00 2001 From: vinit bliro Date: Mon, 9 Jun 2025 00:41:00 +0530 Subject: [PATCH 4/4] refactor: enhance cross-platform compatibility in dev.sh script --- scripts/dev.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/dev.sh b/scripts/dev.sh index 4ae82ee..93ed942 100644 --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -1,9 +1,12 @@ -if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then +case "$OSTYPE" in + msys*|cygwin*|win32*) SAM_CMD="sam.cmd" -else + ;; + *) SAM_CMD="sam" -fi + ;; +esac go mod tidy -$SAM_CMD build -$SAM_CMD local start-api --env-vars env.json \ No newline at end of file +"$SAM_CMD" build +"$SAM_CMD" local start-api --env-vars env.json \ No newline at end of file