-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add env to prevent duplicate runtime loading
- Loading branch information
Showing
3 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,51 @@ | ||
# Copypaste this files as .env and fill blanks | ||
|
||
# used to ensure this env files is loaded exactly one | ||
ENV_FILE_LOADED=true | ||
|
||
PORT=3012 | ||
|
||
# https://yandex.cloud/ru/docs/serverless-containers/quickstart/container#cli_1 | ||
REGISTRY_NAME="nezort11-registry" | ||
CONTAINER_NAME="serverless-curl-impersonate" | ||
SERVICE_ACCOUNT_ID="..." | ||
|
||
# CONTAINER_NUMBER="" | ||
|
||
# # https://github.com/FOSWLY/vot-cli/blob/main/src/config/config.js | ||
# # EXPIRES AFTER SOME TIME | ||
# YANDEX_TRANSLATE_HMAC_SHA254_SECRET="" | ||
|
||
# BOT_TOKEN_PROD="" | ||
# BOT_TOKEN_DEV="" | ||
# BOT_PUBLIC_USERNAME="" | ||
# OWNER_USERNAME="" | ||
|
||
# APP_ID="" | ||
# APP_HASH="" | ||
# # npx tglogin | ||
# SESSION_PROD="" | ||
# SESSION_DEV="" | ||
|
||
# NOTIFICATION_BOT_TOKEN="" | ||
# NOTIFICATION_USER_ID="" | ||
# STORAGE_CHANNEL_CHAT_ID="" | ||
|
||
# SENTRY_DSN="" | ||
|
||
# IMAGE_TRANSLATE_URL="" | ||
|
||
# LOGGING_CHANNEL_ID="" | ||
|
||
# # REGISTRY_NAME="" | ||
# # CONTAINER_NAME="" | ||
# # IMAGE_NAME="" | ||
# # SERVICE_ACCOUNT_ID="" | ||
# # CONTAINER_DOMAIN="" | ||
|
||
# # UPLOADER_URL_PROD="http://telegram_upload:3000" | ||
# # UPLOADER_URL_DEV="http://127.0.0.1:3000" | ||
|
||
# # SERVER_PASSWORD="" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import dotenv from "dotenv"; | ||
|
||
export const DEBUG_ENV = process.env.DEBUG_ENV; | ||
console.log("DEBUG_ENV", DEBUG_ENV); | ||
export const NODE_ENV = process.env.NODE_ENV; | ||
console.log("NODE_ENV", NODE_ENV); | ||
export const IS_PRODUCTION = process.env.NODE_ENV !== "development"; | ||
|
||
// otherwise loaded directly by docker env/env_file | ||
if (DEBUG_ENV) { | ||
// ensure env is loaded once (prevent duplicate loading) | ||
// otherwise loaded directly by docker env/env_file or serverless environment/etc. | ||
if (!process.env.ENV_FILE_LOADED) { | ||
// const dotenv = await import("dotenv/lib/main"); // this produces ERROR cuz of dotenv package.json exports field | ||
// const dotenv = await import("dotenv"); // required ESNext module which breaks a lot | ||
dotenv.config({ path: "./.env" }); // mutates process.env from .env | ||
} | ||
|
||
export const DEBUG_ENV = process.env.DEBUG_ENV === "true"; | ||
console.log("DEBUG_ENV", DEBUG_ENV); | ||
|
||
export const PORT = process.env.PORT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters