Skip to content

Commit 009a245

Browse files
committed
docs(env): restructure .env.example and update comments
- Reorganize .env.example into sections for better readability - Improve comments with clearer instructions and examples - Move conditional push notification provider settings to a new section - Add default values and descriptions for rate limiting settings - Update section on optional settings at the end
1 parent 4e18a88 commit 009a245

File tree

1 file changed

+73
-63
lines changed

1 file changed

+73
-63
lines changed

.env.example

Lines changed: 73 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,94 @@
11
# This is an example environment file.
22
# Copy this file to .env and fill in your actual configuration values.
3-
# The .env file is ignored by Git and should NOT be committed.
3+
# The .env file is git-ignored and should NOT be committed to source control.
44

5-
# REQUIRED: The full connection string for your MongoDB instance.
6-
# DATABASE_URL="mongodb://user:password@localhost:27017/flutter_news_app_api_server_full_source_code_db"
5+
# -----------------------------------------------------------------------------
6+
# SECTION 1: CORE APPLICATION CONFIGURATION (REQUIRED)
7+
# These variables are essential for the server to start and function correctly.
8+
# -----------------------------------------------------------------------------
79

8-
# REQUIRED: A secure, randomly generated secret for signing JWTs.
9-
# JWT_SECRET_KEY="your-super-secret-and-long-jwt-key"
10+
# The full connection string for your MongoDB instance.
11+
DATABASE_URL="mongodb://user:password@localhost:27017/flutter_news_app_api_server_full_source_code_db"
1012

11-
# OPTIONAL: The duration for which a JWT is valid, in hours.
12-
# Defaults to 720 hour (1 month) if not specified.
13-
# JWT_EXPIRY_HOURS="720"
13+
# A secure, randomly generated secret for signing JSON Web Tokens (JWTs).
14+
JWT_SECRET_KEY="your-super-secret-and-long-jwt-key"
1415

15-
# REQUIRED FOR PRODUCTION: The specific origin URL of your web client.
16-
# This allows the client (e.g., the HT Dashboard) to make requests to the API.
16+
# REQUIRED FOR PRODUCTION: The specific origin URL of your web client (e.g., the dashboard).
17+
# This is critical for allowing the web app to make requests to the API.
1718
# For local development, this can be left unset as 'localhost' is allowed by default.
18-
# CORS_ALLOWED_ORIGIN="https://your-dashboard.com"
19+
CORS_ALLOWED_ORIGIN="https://your-dashboard.com"
1920

20-
# REQUIRED: Your SendGrid API key for sending emails.
21-
# SENDGRID_API_KEY="your-sendgrid-api-key"
21+
# Sets the single administrator account for the application.
22+
# On server startup, the system ensures that the user with this email is the
23+
# one and only administrator.
24+
OVERRIDE_ADMIN_EMAIL="admin@example.com"
2225

23-
# REQUIRED: The default email address to send emails from.
24-
# DEFAULT_SENDER_EMAIL="noreply@example.com"
2526

26-
# REQUIRED: The SendGrid template ID for the OTP email.
27-
# OTP_TEMPLATE_ID="d-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
27+
# -----------------------------------------------------------------------------
28+
# SECTION 2: EMAIL SERVICE (SENDGRID) (REQUIRED)
29+
# Credentials for sending transactional emails (e.g., sign-in codes).
30+
# -----------------------------------------------------------------------------
2831

29-
# OPTIONAL: The base URL for the SendGrid API.
30-
# Defaults to "https://api.sendgrid.com" if not set.
31-
# Use "https://api.eu.sendgrid.com" for EU-based accounts.
32-
# SENDGRID_API_URL="https://api.sendgrid.com"
32+
# Your SendGrid API key.
33+
SENDGRID_API_KEY="your-sendgrid-api-key"
3334

34-
# REQUIRED: Sets the single administrator account for the application.
35-
# On server startup, the system ensures that the user with this email is the
36-
# one and only administrator.
37-
# - If no admin exists, one will be created with this email.
38-
# - If an admin with a DIFFERENT email exists, they will be REMOVED and
39-
# replaced by a new admin with this email.
40-
# - If an admin with this email already exists, nothing changes.
41-
# This provides a secure way to set or recover the admin account.
42-
# OVERRIDE_ADMIN_EMAIL="admin@example.com"
43-
44-
# OPTIONAL: Limit for the /auth/request-code endpoint (requests per window).
35+
# The default email address to send emails from.
36+
DEFAULT_SENDER_EMAIL="noreply@example.com"
37+
38+
# The SendGrid template ID for the One-Time Password (OTP) email.
39+
OTP_TEMPLATE_ID="d-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
40+
41+
42+
# -----------------------------------------------------------------------------
43+
# SECTION 3: PUSH NOTIFICATION PROVIDERS (CONDITIONALLY REQUIRED)
44+
# Provide credentials for at least one provider if you intend to use push notifications.
45+
# The server will start without these, but the corresponding clients will be disabled.
46+
# -----------------------------------------------------------------------------
47+
48+
# --- Firebase Cloud Messaging (FCM) ---
49+
# Required if you plan to use Firebase as your push provider.
50+
FIREBASE_PROJECT_ID="your-firebase-project-id"
51+
FIREBASE_CLIENT_EMAIL="your-firebase-client-email"
52+
FIREBASE_PRIVATE_KEY="your-firebase-private-key"
53+
54+
# --- OneSignal ---
55+
# Required if you plan to use OneSignal as your push provider.
56+
# Note: For Android, OneSignal uses FCM infrastructure for delivery. You must
57+
# configure your FCM Server Key in the OneSignal dashboard. However, this
58+
# server only needs the OneSignal App ID and REST API Key to communicate
59+
# with the OneSignal API.
60+
ONESIGNAL_APP_ID="your-onesignal-app-id"
61+
ONESIGNAL_REST_API_KEY="your-onesignal-rest-api-key"
62+
63+
64+
# -----------------------------------------------------------------------------
65+
# SECTION 4: API SECURITY & RATE LIMITING (OPTIONAL)
66+
# Fine-tune security settings. Defaults are provided if these are not set.
67+
# -----------------------------------------------------------------------------
68+
69+
# Limit for the /auth/request-code endpoint (requests per window). Defaults to 3.
4570
# RATE_LIMIT_REQUEST_CODE_LIMIT=3
4671

47-
# OPTIONAL: Window for the /auth/request-code endpoint, in hours.
72+
# Window for the /auth/request-code endpoint, in hours. Defaults to 24.
4873
# RATE_LIMIT_REQUEST_CODE_WINDOW_HOURS=24
4974

50-
# OPTIONAL: Limit for the generic /data API endpoints (requests per window).
75+
# Limit for the generic /data API endpoints (requests per window). Defaults to 1000.
5176
# RATE_LIMIT_DATA_API_LIMIT=1000
5277

53-
# OPTIONAL: Window for the /data API endpoints, in minutes.
78+
# Window for the /data API endpoints, in minutes. Defaults to 60.
5479
# RATE_LIMIT_DATA_API_WINDOW_MINUTES=60
5580

56-
# OPTIONAL: The cache duration for the CountryQueryService, in minutes.
57-
# Defaults to 15 minutes if not specified.
58-
# COUNTRY_SERVICE_CACHE_MINUTES=15
5981

60-
# CONDITIONALLY REQUIRED: The Firebase Project ID for push notifications.
61-
# The server will start without this, but it is required to use Firebase for notifications.
62-
# This is part of your Firebase service account credentials.
63-
# FIREBASE_PROJECT_ID="your-firebase-project-id"
64-
65-
# CONDITIONALLY REQUIRED: The Firebase Client Email for push notifications.
66-
# The server will start without this, but it is required to use Firebase for notifications.
67-
# This is part of your Firebase service account credentials.
68-
# FIREBASE_CLIENT_EMAIL="your-firebase-client-email"
69-
70-
# CONDITIONALLY REQUIRED: The Firebase Private Key for push notifications.
71-
# The server will start without this, but it is required to use Firebase for notifications.
72-
# This is part of your Firebase service account credentials.
73-
# Ensure this is stored securely and correctly formatted (e.g., replace newlines with \n if needed for single-line env var).
74-
# FIREBASE_PRIVATE_KEY="your-firebase-private-key"
75-
76-
# CONDITIONALLY REQUIRED: The OneSignal App ID for push notifications.
77-
# The server will start without this, but it is required to use OneSignal for notifications.
78-
# This identifies your application within OneSignal.
79-
# ONESIGNAL_APP_ID="your-onesignal-app-id"
80-
81-
# CONDITIONALLY REQUIRED: The OneSignal REST API Key for server-side push notifications.
82-
# The server will start without this, but it is required to use OneSignal for notifications.
83-
# This is used to authenticate with the OneSignal API.
84-
# ONESIGNAL_REST_API_KEY="your-onesignal-rest-api-key"
82+
# -----------------------------------------------------------------------------
83+
# SECTION 5: ADVANCED & MISCELLANEOUS CONFIGURATION (OPTIONAL)
84+
# -----------------------------------------------------------------------------
85+
86+
# The duration for which a JWT is valid, in hours. Defaults to 720 (30 days).
87+
# JWT_EXPIRY_HOURS="720"
88+
89+
# The base URL for the SendGrid API. Defaults to "https://api.sendgrid.com".
90+
# Use "https://api.eu.sendgrid.com" for EU-based accounts.
91+
# SENDGRID_API_URL="https://api.sendgrid.com"
92+
93+
# The cache duration for the CountryQueryService, in minutes. Defaults to 15.
94+
# COUNTRY_SERVICE_CACHE_MINUTES=15

0 commit comments

Comments
 (0)