Skip to content

Configuration

1. Environment Variables

Core keys come from @venizia/ignis / @nx/core; service-specific keys are in src/common/environments.ts.

Core / Runtime

NameTypeDefaultRequiredDescription
APP_ENV_SERVER_PORTnumber1190 ⚠️HTTP listen port (odd vs 310x0 siblings)
APP_ENV_BASE_PATHstring/v1/apiRoute prefix (no per-service segment)
APP_ENV_KAFKA_BROKERSstringComma-separated brokers
APP_ENV_KAFKA_CLIENT_IDstringSVC-00150-INVOICE_CONSUMERDefault fallback (${ServiceCodes.INVOICE}_CONSUMER); env sets SVC-00150-INVOICE
APP_ENV_KAFKA_GROUP_IDstringSVC-00150-INVOICE_CONSUMER_GROUPConsumer group; env sets SVC-00150-INVOICE-LOCAL
APP_ENV_APPLICATION_TIMEZONEstringAsia/Ho_Chi_MinhCron timezone

BullMQ Redis

NameTypeDefaultRequiredDescription
APP_ENV_INVOICE_BULLMQ_REDIS_MODEsingle|clusterConnection mode
APP_ENV_INVOICE_BULLMQ_REDIS_HOST / _PORTstring/numberSingle-mode host/port
APP_ENV_INVOICE_BULLMQ_REDIS_PASSWORD / _DATABASEstring/numberAuth / db index
APP_ENV_INVOICE_BULLMQ_REDIS_CLUSTER_NODESstringCluster-mode nodes
APP_ENV_INVOICE_BULLMQ_REDIS_MAX_RETRYnumberConnection retry
APP_ENV_INVOICE_ISSUANCE_WORKER_CONCURRENCYnumber10Issuance worker concurrency (claim-expiry fixed at 3)

Providers & Webhooks

NameTypeRequiredDescription
APP_ENV_VNIS_DEFAULT_TAX_CODE / _CLIENT_ID / _CLIENT_SECRETstringVNIS default connection (seeded into Configuration)
APP_ENV_TVAN_API_KEYstringT-VAN credential (seeded, encrypted)
APP_ENV_VNPAY_TVAN_NAME / _API_KEYstringVNPAY T-VAN naming/key
APP_ENV_INVOICE_WEBHOOK_SECRETstringMerchant→platform webhook (VNPAY/iiapi callback)
APP_ENV_INVOICE_WEBHOOK_INTERNAL_SECRETstringiiapi/commerce→platform internal webhook (HMAC-SHA256)
APP_ENV_INVOICE_WEBHOOK_CALLBACK_URL / _INTERNAL_BASE_URLstringCallback URLs
APP_ENV_INVOICE_CREDENTIALS_KEYstringAES-256-GCM key — exactly 32 bytes / 64 hex (openssl rand -hex 32)
APP_ENV_INVOICE_CLAIM_BASE_URLstringBuyer self-service claim link base

⚠️ APP_ENV_..._WORKER_ID (snowflake) is not configured — see Operations.

2. Feature Flags

FlagSourceDefaultDescription
Scheduled issuanceConfiguration row INVOICE_SCHEDULED_ISSUANCE.jValue.enabledtrueCron batch issuance on/off
Issuance modeInvoiceProviderConfig.issuanceModeMANUALPer-config: REAL_TIME / MANUAL / SCHEDULED / BUYER_SELF_SERVICE
autoRelease / autoSign / autoSendCqt / isSendMailInvoiceProviderConfigfalsePer-config export policy

3. Seeded Data

Migration processes in src/migrations/processes/ — idempotent (existence-checked), run via bun run migrate:dev.

FileSeedsIdempotent
invoice-0001-seed-configurations.ts3 Configuration rows (VNIS, T-VAN, scheduled issuance)
invoice-0002-seed-webhook-configs.tscommerce webhook config (INVOICE_COMMERCE_EVENTSORGANIZER_HQ_CHANGED)
invoice-0003-seed-permissions.tsinvoice permissions
invoice-0004-seed-role-permissions.tsrole↔permission grants
(VN administrative data)provinces / wards / administrative units

4. Configuration Storage (Configuration table)

Per-environment runtime configs; credentials AES-256-GCM encrypted via encryptText.

CodejValueCredentialRead by
VNIS_DEFAULT_CONNECTION{ taxCode, provider, clientId }clientSecret (encrypted)InvoiceProviderConnectionComponent
TVAN_DEFAULT_CONNECTION{ provider, name }apiKey (encrypted)TVanConnectionComponent
INVOICE_SCHEDULED_ISSUANCE{ enabled, cronTime: '0 23 * * *', batchSize: 200 }CronComponent / InvoiceScheduledIssuanceService

Per-merchant credentials (InvoiceProvider.password, .webhookSecret) are encrypted on the provider row, not in Configuration.

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.