feat: implement game API with TRPC and Redis transport

- Added GameApiConfig interface and configuration resolver from environment variables.
- Created GameApiContext for managing database and transport dependencies.
- Implemented InMemoryTurnDaemonTransport for testing purposes.
- Developed RedisTurnDaemonTransport for command and status handling via Redis streams.
- Defined TurnDaemonStreamKeys for namespacing Redis streams by profile.
- Established TRPC router with endpoints for health check, world state retrieval, and turn daemon commands (run, pause, resume, status).
- Integrated Fastify server with TRPC and Redis transport.
- Added unit tests for router functionality and stream key generation.
- Configured Vitest for testing environment.
This commit is contained in:
2025-12-30 01:04:52 +00:00
parent d6c4a4ae25
commit 1688ca0d23
16 changed files with 1036 additions and 3 deletions
+28 -1
View File
@@ -1 +1,28 @@
export {};
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { runGameApiServer } from './server.js';
export * from './config.js';
export * from './context.js';
export * from './router.js';
export * from './server.js';
export * from './daemon/types.js';
export * from './daemon/streamKeys.js';
export * from './daemon/transport.js';
export * from './daemon/inMemoryTransport.js';
export * from './daemon/redisTransport.js';
const isMain = (): boolean => {
if (!process.argv[1]) {
return false;
}
return fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
};
if (isMain()) {
runGameApiServer().catch((error) => {
console.error('[game-api] failed to start', error);
process.exitCode = 1;
});
}