From c687d16aa596494c9dae990ae9bb3d79aad6ccca Mon Sep 17 00:00:00 2001 From: w8385 Date: Tue, 17 Nov 2026 22:17:16 +0900 Subject: [PATCH] refactor: organize source by architectural layer --- ARCHITECTURE.md | 45 ++++++++ README.md | 10 ++ .../http/bearer-authorization.ts} | 24 ++-- src/{ => adapters/http}/cors-policy.ts | 0 .../http/gateway-handler.ts} | 12 +- src/{ => adapters/http}/request-headers.ts | 0 src/{ => adapters/http}/request-target.ts | 8 +- .../solved/solved-client.ts} | 6 +- src/application/parsed-request-target.ts | 5 + .../v4-request-contract.ts} | 8 +- src/{routes.ts => application/v4-router.ts} | 6 +- src/domain/bearer-authorization.ts | 26 +++++ src/domain/solved-client-credentials.ts | 4 + src/{ => domain}/uri-schema.ts | 0 src/{ => domain}/v4-operation-contract.ts | 0 src/generated/v4-operations.ts | 2 +- .../runtime-config.ts} | 7 +- src/server.ts | 6 +- ...n.test.ts => bearer-authorization.test.ts} | 6 +- test/cors-policy.test.ts | 2 +- test/{app.test.ts => gateway-handler.test.ts} | 5 +- test/request-target.test.ts | 2 +- ...{config.test.ts => runtime-config.test.ts} | 2 +- ...-handler.test.ts => solved-client.test.ts} | 6 +- test/source-layout.test.mjs | 107 ++++++++++++++++++ test/v4-operation-manifest.test.ts | 2 +- ...ct.test.ts => v4-request-contract.test.ts} | 13 ++- tool/generate-v4-operation-manifest.mjs | 2 +- tool/mock-load.mjs | 2 +- 29 files changed, 250 insertions(+), 68 deletions(-) create mode 100644 ARCHITECTURE.md rename src/{authorization.ts => adapters/http/bearer-authorization.ts} (67%) rename src/{ => adapters/http}/cors-policy.ts (100%) rename src/{app.ts => adapters/http/gateway-handler.ts} (97%) rename src/{ => adapters/http}/request-headers.ts (100%) rename src/{ => adapters/http}/request-target.ts (95%) rename src/{proxy-handler.ts => adapters/solved/solved-client.ts} (97%) create mode 100644 src/application/parsed-request-target.ts rename src/{contract.ts => application/v4-request-contract.ts} (91%) rename src/{routes.ts => application/v4-router.ts} (97%) create mode 100644 src/domain/bearer-authorization.ts create mode 100644 src/domain/solved-client-credentials.ts rename src/{ => domain}/uri-schema.ts (100%) rename src/{ => domain}/v4-operation-contract.ts (100%) rename src/{config.ts => infrastructure/runtime-config.ts} (96%) rename test/{authorization.test.ts => bearer-authorization.test.ts} (90%) rename test/{app.test.ts => gateway-handler.test.ts} (99%) rename test/{config.test.ts => runtime-config.test.ts} (98%) rename test/{proxy-handler.test.ts => solved-client.test.ts} (98%) create mode 100644 test/source-layout.test.mjs rename test/{contract.test.ts => v4-request-contract.test.ts} (97%) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 0000000..5cc354c --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,45 @@ +# Architecture + +`solved-proxy` keeps the runtime small, but its source tree has explicit +boundaries so new v4 capabilities do not accumulate in a flat directory. + +```text +src/ +├── domain/ Pure gateway values and official v4 contract types +├── generated/ Deterministic artifacts derived from the pinned OpenAPI +├── application/ Route compilation and reviewed request-contract logic +├── adapters/ +│ ├── http/ Inbound Node HTTP parsing, CORS, auth, and request handling +│ └── solved/ Outbound solved.ac HTTP client +├── infrastructure/ Runtime configuration and secret-file loading +└── server.ts Composition root and process lifecycle +``` + +## Dependency direction + +- `domain` depends only on itself and platform primitives. +- `generated` may depend on `domain` types, never on runtime adapters. +- `application` may depend on `domain`, `generated`, and other application + modules. +- `infrastructure` constructs domain values but does not import application or + adapters. +- `adapters` may depend on application and domain contracts. The outbound + solved.ac adapter must not depend on the inbound HTTP adapter. +- `server.ts` is the composition root and may wire adapters and infrastructure. + +`adapters/http/gateway-handler.ts` is intentionally a composition-aware inbound +adapter for this small service: it resolves the application contract and calls +the reviewed solved.ac adapter. This is the single documented adapter-to-adapter +orchestration point. It can be split into a separate use-case layer if runtime +flows become substantially more complex. + +The source-layout test enforces the root shape and the lower-layer dependency +direction. Keep tests flat under `test/` so Node's test command remains simple; +their filenames mirror the production module roles. + +## Generated boundaries + +Files under `src/generated/` are never edited directly. The OpenAPI snapshot, +wire declarations, and operation manifest remain deterministic inputs to the +application layer. See the update and verification commands in +[`README.md`](README.md). diff --git a/README.md b/README.md index b07971b..2864e51 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,16 @@ The build emits JavaScript to `dist/`. Tests use Node's built-in test runner and stub upstream `fetch`; they need no external network access. The load-tool test binds only an ephemeral loopback port. +## Source architecture + +Runtime code is grouped into `domain`, `application`, inbound/outbound +`adapters`, and `infrastructure` layers; `src/server.ts` is the only root +TypeScript file and acts as the composition root. Generated OpenAPI artifacts +remain isolated under `src/generated`. The dependency direction and the one +documented gateway orchestration boundary are described in +[`ARCHITECTURE.md`](ARCHITECTURE.md) and enforced by an offline source-layout +test. + ## Official OpenAPI contract The complete machine-readable solved.ac v4 contract is pinned at diff --git a/src/authorization.ts b/src/adapters/http/bearer-authorization.ts similarity index 67% rename from src/authorization.ts rename to src/adapters/http/bearer-authorization.ts index a3cfdf8..a0d53df 100644 --- a/src/authorization.ts +++ b/src/adapters/http/bearer-authorization.ts @@ -1,13 +1,10 @@ +import { + createBearerAuthorization, + type BearerAuthorization, +} from '../../domain/bearer-authorization.js'; import { readUniqueRawHeader } from './request-headers.js'; const MAX_BEARER_HEADER_BYTES = 4_096; -const BEARER_TOKEN = /^[A-Za-z0-9\-._~+/]+=*$/u; -declare const bearerAuthorizationBrand: unique symbol; - -export type BearerAuthorization = Readonly<{ - token: string; - [bearerAuthorizationBrand]: true; -}>; export type BearerAuthorizationResult = | { readonly kind: 'absent' } @@ -30,23 +27,16 @@ export function parseBearerAuthorization( const separator = header.value.indexOf(' '); const scheme = header.value.slice(0, separator); const token = header.value.slice(separator + 1); + const authorization = createBearerAuthorization(token); if ( separator < 1 || scheme.toLowerCase() !== 'bearer' || - !BEARER_TOKEN.test(token) + authorization === undefined ) { return { kind: 'invalid' }; } return { kind: 'valid', - authorization: Object.freeze({ - token, - }) as BearerAuthorization, + authorization, }; } - -export function bearerAuthorizationHeader( - authorization: BearerAuthorization, -): string { - return `Bearer ${authorization.token}`; -} diff --git a/src/cors-policy.ts b/src/adapters/http/cors-policy.ts similarity index 100% rename from src/cors-policy.ts rename to src/adapters/http/cors-policy.ts diff --git a/src/app.ts b/src/adapters/http/gateway-handler.ts similarity index 97% rename from src/app.ts rename to src/adapters/http/gateway-handler.ts index d30e2d2..6da23be 100644 --- a/src/app.ts +++ b/src/adapters/http/gateway-handler.ts @@ -1,23 +1,21 @@ import type { IncomingMessage, RequestListener, ServerResponse } from 'node:http'; -import { - parseBearerAuthorization, - type BearerAuthorization, -} from './authorization.js'; +import type { BearerAuthorization } from '../../domain/bearer-authorization.js'; +import { parseBearerAuthorization } from './bearer-authorization.js'; import { ContractError, resolveProxyRequest, SOLVED_API_BASE_URL, -} from './contract.js'; +} from '../../application/v4-request-contract.js'; import { corsDecision } from './cors-policy.js'; import { proxyRequest, type ProxyDependencies, type ProxyRequestPolicy, UpstreamError, -} from './proxy-handler.js'; +} from '../solved/solved-client.js'; import { parseRequestTarget } from './request-target.js'; -import { findRoute } from './routes.js'; +import { findRoute } from '../../application/v4-router.js'; export const DEFAULT_MAX_CONCURRENT_REQUESTS = 8; diff --git a/src/request-headers.ts b/src/adapters/http/request-headers.ts similarity index 100% rename from src/request-headers.ts rename to src/adapters/http/request-headers.ts diff --git a/src/request-target.ts b/src/adapters/http/request-target.ts similarity index 95% rename from src/request-target.ts rename to src/adapters/http/request-target.ts index 8e51432..d1444bf 100644 --- a/src/request-target.ts +++ b/src/adapters/http/request-target.ts @@ -1,15 +1,11 @@ +import type { ParsedRequestTarget } from '../../application/parsed-request-target.js'; + export const MAX_REQUEST_TARGET_BYTES = 8_192; const INVALID_RAW_TARGET = /[\p{Cc}\u0020]/u; const INVALID_DECODED_COMPONENT = /\p{Cc}/u; const VALID_PERCENT_ESCAPE = /^[0-9A-Fa-f]{2}$/u; -export interface ParsedRequestTarget { - readonly url: URL; - readonly pathname: string; - readonly decodedPathSegments: readonly string[]; -} - function hasValidPercentEncoding(value: string): boolean { for (let index = 0; index < value.length; index += 1) { if (value[index] !== '%') { diff --git a/src/proxy-handler.ts b/src/adapters/solved/solved-client.ts similarity index 97% rename from src/proxy-handler.ts rename to src/adapters/solved/solved-client.ts index 0fdbcb2..e26f935 100644 --- a/src/proxy-handler.ts +++ b/src/adapters/solved/solved-client.ts @@ -1,9 +1,9 @@ import { bearerAuthorizationHeader, type BearerAuthorization, -} from './authorization.js'; -import type { SolvedClientCredentials } from './config.js'; -import type { V4ResponseContract } from './v4-operation-contract.js'; +} from '../../domain/bearer-authorization.js'; +import type { SolvedClientCredentials } from '../../domain/solved-client-credentials.js'; +import type { V4ResponseContract } from '../../domain/v4-operation-contract.js'; export const DEFAULT_UPSTREAM_TIMEOUT_MS = 8_000; export const DEFAULT_MAX_RESPONSE_BYTES = 5 * 1_024 * 1_024; diff --git a/src/application/parsed-request-target.ts b/src/application/parsed-request-target.ts new file mode 100644 index 0000000..90f8e74 --- /dev/null +++ b/src/application/parsed-request-target.ts @@ -0,0 +1,5 @@ +export interface ParsedRequestTarget { + readonly url: URL; + readonly pathname: string; + readonly decodedPathSegments: readonly string[]; +} diff --git a/src/contract.ts b/src/application/v4-request-contract.ts similarity index 91% rename from src/contract.ts rename to src/application/v4-request-contract.ts index 85a110e..327cd78 100644 --- a/src/contract.ts +++ b/src/application/v4-request-contract.ts @@ -1,7 +1,7 @@ -import type { ParsedRequestTarget } from './request-target.js'; -import { findRoute } from './routes.js'; -import type { V4ResponseContract } from './v4-operation-contract.js'; -import { validateUriValue } from './uri-schema.js'; +import type { V4ResponseContract } from '../domain/v4-operation-contract.js'; +import { validateUriValue } from '../domain/uri-schema.js'; +import type { ParsedRequestTarget } from './parsed-request-target.js'; +import { findRoute } from './v4-router.js'; export const SOLVED_API_BASE_URL = 'https://solved.ac/' as const; diff --git a/src/routes.ts b/src/application/v4-router.ts similarity index 97% rename from src/routes.ts rename to src/application/v4-router.ts index 3dc83f6..8ceca49 100644 --- a/src/routes.ts +++ b/src/application/v4-router.ts @@ -1,12 +1,12 @@ -import { V4_OPERATION_MANIFEST } from './generated/v4-operations.js'; +import { V4_OPERATION_MANIFEST } from '../generated/v4-operations.js'; import type { V4OperationContract, V4OperationParameter, -} from './v4-operation-contract.js'; +} from '../domain/v4-operation-contract.js'; import { assertUriSchemaSupported, validateUriValue, -} from './uri-schema.js'; +} from '../domain/uri-schema.js'; const PATH_PARAMETER = /^\{([A-Za-z][A-Za-z0-9]*)\}$/u; const EXPECTED_GET_OPERATIONS = 71; diff --git a/src/domain/bearer-authorization.ts b/src/domain/bearer-authorization.ts new file mode 100644 index 0000000..15c9944 --- /dev/null +++ b/src/domain/bearer-authorization.ts @@ -0,0 +1,26 @@ +const MAX_BEARER_TOKEN_BYTES = 4_089; +const BEARER_TOKEN = /^[A-Za-z0-9\-._~+/]+=*$/u; +declare const bearerAuthorizationBrand: unique symbol; + +export type BearerAuthorization = Readonly<{ + token: string; + [bearerAuthorizationBrand]: true; +}>; + +export function createBearerAuthorization( + token: string, +): BearerAuthorization | undefined { + if ( + Buffer.byteLength(token, 'utf8') > MAX_BEARER_TOKEN_BYTES || + !BEARER_TOKEN.test(token) + ) { + return undefined; + } + return Object.freeze({ token }) as BearerAuthorization; +} + +export function bearerAuthorizationHeader( + authorization: BearerAuthorization, +): string { + return `Bearer ${authorization.token}`; +} diff --git a/src/domain/solved-client-credentials.ts b/src/domain/solved-client-credentials.ts new file mode 100644 index 0000000..67fd270 --- /dev/null +++ b/src/domain/solved-client-credentials.ts @@ -0,0 +1,4 @@ +export interface SolvedClientCredentials { + readonly clientId: string; + readonly clientSecret: string; +} diff --git a/src/uri-schema.ts b/src/domain/uri-schema.ts similarity index 100% rename from src/uri-schema.ts rename to src/domain/uri-schema.ts diff --git a/src/v4-operation-contract.ts b/src/domain/v4-operation-contract.ts similarity index 100% rename from src/v4-operation-contract.ts rename to src/domain/v4-operation-contract.ts diff --git a/src/generated/v4-operations.ts b/src/generated/v4-operations.ts index 728300a..5f022d7 100644 --- a/src/generated/v4-operations.ts +++ b/src/generated/v4-operations.ts @@ -3,7 +3,7 @@ * Snapshot SHA-256: 312abfb4677fc67d914f6a357ff5b89d170eb65791ecb5d3ab30ab873352125d * Do not edit directly; run npm run openapi:operations:update. */ -import type { V4OperationManifest } from '../v4-operation-contract.js'; +import type { V4OperationManifest } from '../domain/v4-operation-contract.js'; export const V4_OPERATION_SNAPSHOT_SHA256 = "312abfb4677fc67d914f6a357ff5b89d170eb65791ecb5d3ab30ab873352125d" as const; diff --git a/src/config.ts b/src/infrastructure/runtime-config.ts similarity index 96% rename from src/config.ts rename to src/infrastructure/runtime-config.ts index 672b877..bb33a10 100644 --- a/src/config.ts +++ b/src/infrastructure/runtime-config.ts @@ -1,14 +1,11 @@ import { readFileSync, statSync } from 'node:fs'; +import type { SolvedClientCredentials } from '../domain/solved-client-credentials.js'; + const MAX_CREDENTIAL_BYTES = 4_096; const MAX_CORS_ORIGINS_BYTES = 8_192; const MAX_CORS_ORIGINS = 32; -export interface SolvedClientCredentials { - readonly clientId: string; - readonly clientSecret: string; -} - export class ConfigurationError extends Error { constructor(message: string) { super(message); diff --git a/src/server.ts b/src/server.ts index 1c41875..07d072a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -4,15 +4,15 @@ import { pathToFileURL } from 'node:url'; import { createRequestHandler, DEFAULT_MAX_CONCURRENT_REQUESTS, -} from './app.js'; +} from './adapters/http/gateway-handler.js'; import { loadProtectedCorsOrigins, loadSolvedClientCredentials, -} from './config.js'; +} from './infrastructure/runtime-config.js'; import { DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_UPSTREAM_TIMEOUT_MS, -} from './proxy-handler.js'; +} from './adapters/solved/solved-client.js'; const DEFAULT_PORT = 3_000; const DEFAULT_HOST = '0.0.0.0'; diff --git a/test/authorization.test.ts b/test/bearer-authorization.test.ts similarity index 90% rename from test/authorization.test.ts rename to test/bearer-authorization.test.ts index 934efe7..2584d96 100644 --- a/test/authorization.test.ts +++ b/test/bearer-authorization.test.ts @@ -1,10 +1,8 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -import { - bearerAuthorizationHeader, - parseBearerAuthorization, -} from '../src/authorization.js'; +import { parseBearerAuthorization } from '../src/adapters/http/bearer-authorization.js'; +import { bearerAuthorizationHeader } from '../src/domain/bearer-authorization.js'; test('parses one bounded RFC 6750 Bearer value and normalizes the scheme', () => { for (const value of [ diff --git a/test/cors-policy.test.ts b/test/cors-policy.test.ts index f66820c..2d59305 100644 --- a/test/cors-policy.test.ts +++ b/test/cors-policy.test.ts @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -import { corsDecision } from '../src/cors-policy.js'; +import { corsDecision } from '../src/adapters/http/cors-policy.js'; const allowedOrigins = ['https://app.example', 'http://localhost:3000']; diff --git a/test/app.test.ts b/test/gateway-handler.test.ts similarity index 99% rename from test/app.test.ts rename to test/gateway-handler.test.ts index 70b54ca..e0c303b 100644 --- a/test/app.test.ts +++ b/test/gateway-handler.test.ts @@ -3,7 +3,10 @@ import { EventEmitter, once } from 'node:events'; import type { IncomingMessage, ServerResponse } from 'node:http'; import test from 'node:test'; -import { createRequestHandler, handleGatewayRequest } from '../src/app.js'; +import { + createRequestHandler, + handleGatewayRequest, +} from '../src/adapters/http/gateway-handler.js'; const text = (body: Uint8Array): string => new TextDecoder().decode(body); const credentials = Object.freeze({ diff --git a/test/request-target.test.ts b/test/request-target.test.ts index e50ce36..45ede55 100644 --- a/test/request-target.test.ts +++ b/test/request-target.test.ts @@ -4,7 +4,7 @@ import test from 'node:test'; import { MAX_REQUEST_TARGET_BYTES, parseRequestTarget, -} from '../src/request-target.js'; +} from '../src/adapters/http/request-target.js'; test('parses path and query components exactly once', () => { const parsed = parseRequestTarget( diff --git a/test/config.test.ts b/test/runtime-config.test.ts similarity index 98% rename from test/config.test.ts rename to test/runtime-config.test.ts index 6399fe6..598fc48 100644 --- a/test/config.test.ts +++ b/test/runtime-config.test.ts @@ -8,7 +8,7 @@ import { ConfigurationError, loadProtectedCorsOrigins, loadSolvedClientCredentials, -} from '../src/config.js'; +} from '../src/infrastructure/runtime-config.js'; function credentialFiles( clientId = 'client-id', diff --git a/test/proxy-handler.test.ts b/test/solved-client.test.ts similarity index 98% rename from test/proxy-handler.test.ts rename to test/solved-client.test.ts index 02374b6..97b01b5 100644 --- a/test/proxy-handler.test.ts +++ b/test/solved-client.test.ts @@ -2,15 +2,15 @@ import assert from 'node:assert/strict'; import { ReadableStream } from 'node:stream/web'; import test from 'node:test'; -import { parseBearerAuthorization } from '../src/authorization.js'; +import { parseBearerAuthorization } from '../src/adapters/http/bearer-authorization.js'; import { V4_OPERATION_MANIFEST } from '../src/generated/v4-operations.js'; import { proxyRequest as proxyUpstream, type ProxyDependencies, type ProxyRequestPolicy, UpstreamError, -} from '../src/proxy-handler.js'; -import type { V4ResponseContract } from '../src/v4-operation-contract.js'; +} from '../src/adapters/solved/solved-client.js'; +import type { V4ResponseContract } from '../src/domain/v4-operation-contract.js'; const upstreamUrl = new URL('https://solved.ac/api/v4/users/tourist'); const responsePolicy = diff --git a/test/source-layout.test.mjs b/test/source-layout.test.mjs new file mode 100644 index 0000000..9a87f97 --- /dev/null +++ b/test/source-layout.test.mjs @@ -0,0 +1,107 @@ +import assert from 'node:assert/strict'; +import { readdir, readFile } from 'node:fs/promises'; +import { dirname, relative, resolve, sep } from 'node:path'; +import test from 'node:test'; +import { fileURLToPath } from 'node:url'; + +const sourceRoot = fileURLToPath(new URL('../src/', import.meta.url)); +const expectedDirectories = [ + 'adapters', + 'application', + 'domain', + 'generated', + 'infrastructure', +]; +const allowedDependencies = { + 'adapters/http': new Set([ + 'adapters/http', + 'application', + 'domain', + ]), + 'adapters/solved': new Set(['adapters/solved', 'domain']), + application: new Set(['application', 'domain', 'generated']), + domain: new Set(['domain']), + generated: new Set(['domain', 'generated']), + infrastructure: new Set(['domain', 'infrastructure']), +}; +const relativeImport = /(?:\bfrom\s*|\bimport\s*)['"](\.[^'"]+)['"]/gu; +const gatewayOrchestrationPath = `adapters${sep}http${sep}gateway-handler.ts`; + +async function sourceFiles(directory) { + const entries = await readdir(directory, { withFileTypes: true }); + const nested = await Promise.all( + entries.map(async (entry) => { + const path = resolve(directory, entry.name); + if (entry.isDirectory()) { + return sourceFiles(path); + } + return entry.isFile() && entry.name.endsWith('.ts') ? [path] : []; + }), + ); + return nested.flat(); +} + +function layerOf(path) { + const pathFromRoot = relative(sourceRoot, path); + assert.equal( + pathFromRoot.startsWith(`..${sep}`) || pathFromRoot === '..', + false, + `source import escapes src/: ${pathFromRoot}`, + ); + const parts = pathFromRoot.split(sep); + return parts[0] === 'adapters' + ? `adapters/${parts[1] ?? ''}` + : parts[0]; +} + +function typescriptTarget(sourceFile, specifier) { + const target = resolve(dirname(sourceFile), specifier); + return target.endsWith('.js') ? `${target.slice(0, -3)}.ts` : target; +} + +function dependenciesFor(sourceFile, sourceLayer) { + const allowed = allowedDependencies[sourceLayer]; + assert.notEqual(allowed, undefined, `unknown source layer: ${sourceLayer}`); + return relative(sourceRoot, sourceFile) === gatewayOrchestrationPath + ? new Set([...allowed, 'adapters/solved']) + : allowed; +} + +test('source root contains only the composition root and reviewed layers', async () => { + const entries = await readdir(sourceRoot, { withFileTypes: true }); + assert.deepEqual( + entries + .filter((entry) => entry.isDirectory()) + .map((entry) => entry.name) + .sort(), + expectedDirectories, + ); + assert.deepEqual( + entries + .filter((entry) => entry.isFile() && entry.name.endsWith('.ts')) + .map((entry) => entry.name) + .sort(), + ['server.ts'], + ); +}); + +test('lower source layers do not import outward', async () => { + for (const sourceFile of await sourceFiles(sourceRoot)) { + const sourceLayer = layerOf(sourceFile); + if (sourceLayer === 'server.ts') { + continue; + } + const allowed = dependenciesFor(sourceFile, sourceLayer); + const source = await readFile(sourceFile, 'utf8'); + for (const match of source.matchAll(relativeImport)) { + const specifier = match[1]; + assert.notEqual(specifier, undefined); + const targetLayer = layerOf(typescriptTarget(sourceFile, specifier)); + assert.equal( + allowed.has(targetLayer), + true, + `${relative(sourceRoot, sourceFile)} imports outward to ${targetLayer}`, + ); + } + } +}); diff --git a/test/v4-operation-manifest.test.ts b/test/v4-operation-manifest.test.ts index f716824..02eec84 100644 --- a/test/v4-operation-manifest.test.ts +++ b/test/v4-operation-manifest.test.ts @@ -8,7 +8,7 @@ import { import type { V4ResponseContract, V4RuntimePolicy, -} from '../src/v4-operation-contract.js'; +} from '../src/domain/v4-operation-contract.js'; const generatedRuntimePolicy = { enabled: true, diff --git a/test/contract.test.ts b/test/v4-request-contract.test.ts similarity index 97% rename from test/contract.test.ts rename to test/v4-request-contract.test.ts index c186618..9f0f4a3 100644 --- a/test/contract.test.ts +++ b/test/v4-request-contract.test.ts @@ -1,16 +1,19 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -import { ContractError, resolveProxyRequest } from '../src/contract.js'; -import { parseRequestTarget } from '../src/request-target.js'; +import { + ContractError, + resolveProxyRequest, +} from '../src/application/v4-request-contract.js'; +import { parseRequestTarget } from '../src/adapters/http/request-target.js'; import { compileGetRouter, GET_OPERATION_KEYS, GET_ROUTES, type V4GetRoute, -} from '../src/routes.js'; -import type { V4RequestSchema } from '../src/v4-operation-contract.js'; -import { validateUriValue } from '../src/uri-schema.js'; +} from '../src/application/v4-router.js'; +import type { V4RequestSchema } from '../src/domain/v4-operation-contract.js'; +import { validateUriValue } from '../src/domain/uri-schema.js'; function requestTarget(raw: string) { const parsed = parseRequestTarget(raw); diff --git a/tool/generate-v4-operation-manifest.mjs b/tool/generate-v4-operation-manifest.mjs index cc6f6b9..b752064 100644 --- a/tool/generate-v4-operation-manifest.mjs +++ b/tool/generate-v4-operation-manifest.mjs @@ -1046,7 +1046,7 @@ export function renderOperationManifest(manifest, snapshotSha256) { * Snapshot SHA-256: ${snapshotSha256} * Do not edit directly; run npm run openapi:operations:update. */ -import type { V4OperationManifest } from '../v4-operation-contract.js'; +import type { V4OperationManifest } from '../domain/v4-operation-contract.js'; export const V4_OPERATION_SNAPSHOT_SHA256 = ${JSON.stringify(snapshotSha256)} as const; diff --git a/tool/mock-load.mjs b/tool/mock-load.mjs index 0ed7d31..e6e747d 100644 --- a/tool/mock-load.mjs +++ b/tool/mock-load.mjs @@ -4,7 +4,7 @@ import assert from 'node:assert/strict'; import { createServer } from 'node:http'; import { performance } from 'node:perf_hooks'; -import { createRequestHandler } from '../dist/src/app.js'; +import { createRequestHandler } from '../dist/src/adapters/http/gateway-handler.js'; const LIMITS = Object.freeze({ requests: Object.freeze({ default: 256, minimum: 16, maximum: 5_000 }),