// Point the DB at a closed port BEFORE requiring the router (some public handlers // build the pool). The /version endpoint itself is DB-free, so it answers without // a connection; this just guarantees no stray query holds the process open. process.env.DB_HOST = '127.0.0.1' process.env.DB_PORT = '59999' const { test, after } = require('node:test') const assert = require('node:assert/strict') const { startApp } = require('./_helper') const version = require('../src/config/version') const publicRouter = require('../src/router/v1/public') const db = require('../src/utils/db') after(() => db.close()) test('version config carries the service id + api/server versions', () => { assert.equal(version.service, 'runic-gateway') // stable first-run identifier assert.equal(version.api, 'v1') // API contract version (matches /api/v1) assert.equal(typeof version.server, 'string') assert.ok(version.server.length > 0) }) test('GET /public/version returns the identity block (DB-free, 200)', async () => { const app = await startApp((a) => a.use('/api/v1/public', publicRouter)) try { const res = await fetch(app.url + '/api/v1/public/version') assert.equal(res.status, 200) const body = await res.json() assert.equal(body.service, 'runic-gateway') assert.equal(body.api, 'v1') assert.equal(body.server, version.server) } finally { await app.close() } })