Files
gold_land_server/test/production-config.test.ts
safavimohadeseh78andCursor dfb20ca92c
Backend CI / type-check, build, tests (push) Successful in 1m0s
feat: prepare six-lesson trial backend with reliable rewards and operations
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-12 14:35:42 +03:30

68 lines
1.4 KiB
TypeScript

import 'reflect-metadata'
import assert from 'node:assert/strict'
import { validateEnv } from '../src/config/env.validation'
const VALID_PROD_SECRET = 'a'.repeat(48)
assert.throws(
() =>
validateEnv({
NODE_ENV: 'production',
PORT: 3000,
HOST: '0.0.0.0',
CORS_ORIGIN: 'https://app.example.com',
JWT_SECRET: '',
}),
/JWT_SECRET is required/,
)
assert.throws(
() =>
validateEnv({
NODE_ENV: 'production',
PORT: 3000,
HOST: '0.0.0.0',
CORS_ORIGIN: 'https://app.example.com',
JWT_SECRET: 'gold-land-dev-secret-change-in-production',
}),
/placeholder/,
)
assert.throws(
() =>
validateEnv({
NODE_ENV: 'production',
PORT: 3000,
HOST: '0.0.0.0',
CORS_ORIGIN: 'https://app.example.com',
JWT_SECRET: 'short',
}),
/32 characters/,
)
assert.throws(
() =>
validateEnv({
NODE_ENV: 'production',
PORT: 3000,
HOST: '0.0.0.0',
CORS_ORIGIN: 'https://app.example.com',
JWT_SECRET: VALID_PROD_SECRET,
TRUST_PROXY: 'true',
}),
/TRUST_PROXY_CIDRS is required/,
)
const ok = validateEnv({
NODE_ENV: 'production',
PORT: 3000,
HOST: '0.0.0.0',
CORS_ORIGIN: 'https://app.example.com',
JWT_SECRET: VALID_PROD_SECRET,
TRUST_PROXY: 'true',
TRUST_PROXY_CIDRS: '172.20.0.0/16',
})
assert.equal(ok.NODE_ENV, 'production')
console.log('production-config tests passed')