/* * ★ The hook address the contract comments give is the address the route answers. * * 2026-10-11: both contract comments said `POST /domain/<도메인>/twin/hook/…`. The route sits on the * domain-public router with no prefix, so the warehouse destination, written from that comment, got 405 * for every fact. The tenant travels in the X-Things-Factory-Domain header (the webhook destination's * params.receivingDomain), not in the path. */ import { test } from 'node:test' import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' const read = (rel: string) => readFileSync(new URL(`../server/${rel}`, import.meta.url), 'utf8') const route = read('routes.ts').match(/router\.post\('([^']*twin\/hook[^']*)'/)?.[1] test('the hook route is registered without a domain prefix', () => { assert.equal(route, '/twin/hook/:source/:instanceId') }) for (const file of ['service/reference/hook-contract.ts', 'service/reference/reference-hook.ts']) { test(`${file} gives the address the route answers`, () => { const line = read(file).match(/주소\s+POST\s+(\S+)/)?.[1] assert.ok(line, 'no address line') assert.equal(line, '/twin/hook/<연결이름>/<트윈>') assert.equal(line.replace(/<[^>]+>/g, 'x'), route!.replace(/:\w+/g, 'x'), 'the comment and the route name different paths') }) }