Skip to content

Configuration

1. Environment Variables

Source: EnvironmentKeys in @nx/core/src/common/environments.ts. Service reads via applicationEnvironment.get<T>(key).

Core runtime

NameTypeDefaultRequiredDescription
APP_ENV_PORTnumber3000HTTP listen port
APP_ENV_HOSTstring0.0.0.0Bind address
APP_ENV_BASE_PATHstring/v1/api/identityRoute prefix
APP_ENV_NODE_IDnumber-Snowflake worker ID - must be 1 for identity
APP_ENV_LOG_LEVELinfo|debug|warn|errorinfo-
APP_ENV_NODE_ENVstringdevelopmentdotenv-flow loader
RUN_MODEmigrate|servermigrate switches to migration entry

Database

NameTypeDefaultRequiredDescription
APP_ENV_DB_URLstring-PostgreSQL connection URL
APP_ENV_DB_POOL_MAXnumber10-

Redis (OTP + auth cache)

NameTypeDefaultRequiredDescription
APP_ENV_REDIS_HOSTstring-OTP requires Redis; auth cache is optional
APP_ENV_REDIS_PORTnumber6379-
APP_ENV_REDIS_PASSWORDstring--
APP_ENV_REDIS_DBnumber0-

JWKS / Token signing

NameTypeDefaultRequiredDescription
APP_ENV_APPLICATION_SECRETstring-Used by CryptoUtility for AES-256-GCM (encrypts mail/SMS configs)
APP_ENV_JWKS_PRIVATE_KEY (or k8s secret)PEM-ES256 private key for signing JWTs
APP_ENV_JWKS_PUBLIC_KEY (or k8s secret)PEM-Counterpart published at /jw-certs

Exact env-var names depend on @nx/core/IssuerApplication configuration. Consult @nx/core JWT helper for the canonical names.

Mail (SMTP)

NameTypeDefaultDescription
APP_ENV_SMTP_HOSTstringsmtp.gmail.comSMTP server
APP_ENV_SMTP_PORTnumber587-
APP_ENV_SMTP_USERNAMEstring--
APP_ENV_SMTP_PASSWORDstring--

WebSocket

NameTypeDefaultDescription
APP_ENV_WEBSOCKET_REDIS_MODESINGLE|CLUSTERSINGLESingle-instance vs Redis Cluster mode for WS emitter

2. Feature Flags

FlagStorageDefaultDescription
OTP enabled per channelConfiguration rowenabledToggle email vs phone OTP
Mail templates per merchantConfiguration per merchantIdglobalOverride system templates

3. Seeded Data

7 migration processes in src/migrations/processes/. Run on bootstrap.

FileScopeNotes
identity-0001-seed-roles.ts6 system rolesSUPER_ADMIN, ADMIN, OPERATOR, OWNER, EMPLOYEE, CUSTOMER (immutable)
identity-0002-seed-users.tsDefault admin/test usersDev convenience
identity-0003-seed-table-configurations.tsOTP/mail/password defaults in ConfigurationOTP TTLs, attempt limits, lockout
identity-0004-seed-mail-configurations.tsMail templates (verify-email, forgot-password, welcome, password-changed × en/vi)8 rows
identity-0005-seed-permissions.tsAll IdentityPermissionsPer-controller CRUD permissions; alwaysRun=true
identity-0006-seed-sms-configurations.tsVN Pay SMS provider configencrypted
identity-0007-seed-sms-templates.tsSMS templates (phone-auth, add-phone × en/vi)4 rows

4. Configuration Table Usage

Identity reads/writes:

Configuration kindGroupEncryptionRead by
Mail validation defaults (CODE_LENGTH, CODE_EXPIRY, etc.)MAIL_VALIDATION-MailValidationFields constants
Mail templatesMAIL-MailTemplateService
OTP policyOTP-BaseOTPBasedMFAService
SMS templatesSMS-SmsTemplateService
SMS provider credentialsSMS_PARAMETER_CONFIGUREAES-256-GCMMQSMSComponent

Templates can be overridden per-merchant via (group, code, principalId, principalType) partial unique index.

5. Boot Order

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