Separate runtime profile identity from scenario

This commit is contained in:
2026-07-26 05:45:45 +00:00
parent 7679e8f5b7
commit bf08c5e658
5 changed files with 43 additions and 1 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ export interface GameApiConfig {
export const resolveGameApiConfigFromEnv = (env: NodeJS.ProcessEnv = process.env): GameApiConfig => {
const profile = env.PROFILE ?? env.SERVER_PROFILE ?? 'hwe';
const scenario = env.SCENARIO ?? 'default';
const profileName = `${profile}:${scenario}`;
const profileName = env.GAME_PROFILE_NAME ?? `${profile}:${scenario}`;
const secret = env.GAME_TOKEN_SECRET ?? env.GATEWAY_TOKEN_SECRET ?? '';
if (!secret) {
throw new Error('GAME_TOKEN_SECRET is required for game token verification.');
+28
View File
@@ -0,0 +1,28 @@
import { describe, expect, it } from 'vitest';
import { resolveGameApiConfigFromEnv } from '../src/config.js';
describe('resolveGameApiConfigFromEnv', () => {
it('keeps the deployment profile identity separate from the scenario id', () => {
const config = resolveGameApiConfigFromEnv({
PROFILE: 'hwe',
SCENARIO: '1010',
GAME_PROFILE_NAME: 'hwe:2',
GAME_TOKEN_SECRET: 'test-secret',
});
expect(config.profile).toBe('hwe');
expect(config.scenario).toBe('1010');
expect(config.profileName).toBe('hwe:2');
});
it('falls back to the legacy profile and scenario pair', () => {
const config = resolveGameApiConfigFromEnv({
PROFILE: 'hwe',
SCENARIO: '2',
GAME_TOKEN_SECRET: 'test-secret',
});
expect(config.profileName).toBe('hwe:2');
});
});