Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add .env.example for easier environment setup and refine .gitignore #15

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ JsonStorage.json
*.crt
*.pem
*.key
*.cnf
*.cnf

# Azurite local storage files
__azurite_db_*
__blobstorage__
__queuestorage__
71 changes: 71 additions & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
##########################################
# Environment Variables for CodePush Server
##########################################

# ==============================
# Storage Configuration (REQUIRED - choose one)
# ==============================
EMULATED=false # Set to 'true' to use the local emulator

# --- Azure Storage Configuration ---
AZURE_STORAGE_ACCOUNT= # Azure storage account name
AZURE_STORAGE_ACCESS_KEY= # Azure storage access key (if KeyVault not used)

# ==============================
# Server Configuration (REQUIRED)
# ==============================
SERVER_URL=http://localhost:3000 # The URL of your server

# ==============================
# Authentication (REQUIRED - at least one provider)
# ==============================

# --- GitHub OAuth ---
GITHUB_CLIENT_ID= # GitHub OAuth client ID
GITHUB_CLIENT_SECRET= # GitHub OAuth client secret

# --- Microsoft OAuth ---
MICROSOFT_CLIENT_ID= # Microsoft OAuth client ID
MICROSOFT_CLIENT_SECRET= # Microsoft OAuth client secret

# ==============================
# Optional Configuration
# ==============================

# --- HTTPS Configuration ---
HTTPS= # Set to 'true' to enable HTTPS for local deployment

# --- Debugging Configuration ---
LOGGING=false # Enable CodePush-specific logging
DEBUG_DISABLE_AUTH=false # Disable OAuth authentication route
DEBUG_USER_ID= # Backend user ID for debugging session

# ==============================
# Redis Configuration
# ==============================
REDIS_HOST= # Redis server IP address
REDIS_PORT=6379 # Redis port (default: 6379)
REDIS_KEY= # Redis authentication key

# ==============================
# Unit Testing Configuration
# ==============================
TEST_AZURE_STORAGE=false # Run API unit tests against Azure storage
AZURE_ACQUISITION_URL= # URL for acquisition tests

# ==============================
# Other Configuration
# ==============================
DISABLE_ACQUISITION=false # Disable acquisition routes
DISABLE_MANAGEMENT=false # Disable management routes
ENABLE_ACCOUNT_REGISTRATION=true # Enable account registration
UPLOAD_SIZE_LIMIT_MB=200 # Max file upload size (in MB)
ENABLE_PACKAGE_DIFFING=false # Enable generating diffs for releases

# ==============================
# Azure KeyVault Configuration (Optional)
# ==============================
AZURE_KEYVAULT_ACCOUNT= # Azure KeyVault account name
CLIENT_ID= # Active Directory app client ID
CERTIFICATE_THUMBPRINT= # AD app certificate thumbprint
REFRESH_CREDENTIALS_INTERVAL=86400000 # Credential refresh interval (in ms, default: 1 day)
2 changes: 1 addition & 1 deletion api/ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The CodePush Server is configured using environment variables.

Currently, the following environment variables are available. For convenience, we will also load the server environment from any '.env' file in the api directory, and the test environment from any '.test.env' file in the root directory.
For convenience, we will also load the server environment from any '.env' file in the api directory, and the test environment from any '.test.env' file in the root directory. Use the `.env.example` file as a template for setting up your environment variables.

## Mandatory parameters

Expand Down
25 changes: 20 additions & 5 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,26 @@ Additionally, you need to specify [EMULATED](ENVIRONMENT.md#emulated) flag equal

#### Steps
To run the CodePush Server locally, follow these steps:
1. Clone the CodePush Service repository.
1. Create a `.env` file and configure the mandatory variables as outlined in the `ENVIRONMENT.md` file.
1. Install dependencies by running `npm install`.
1. Build the server by running `npm run build`.
1. Start the server by running `npm run start:env`.

1. Clone the CodePush Service repository to your local machine.

2. Copy the `.env.example` file to a new file named `.env` in the root directory:
````bash
cp .env.example .env
````
Fill in the values for each environment variable in the `.env` file according to your development or production setup.
lucen-ms marked this conversation as resolved.
Show resolved Hide resolved
3. Install all necessary dependencies:
````bash
npm install
````
4. Compile the server code:
````bash
npm run build
````
5. Launch the server with the environment-specific start command:
````bash
npm run start:env
````

By default, local CodePush server runs on HTTP. To run CodePush Server on HTTPS:

Expand Down