Skip to report

Server plugins enter oRPC’s request handler

Trace oRPC’s server plugin layer into the standard request handler it is wired into, starting with CORS handling and procedure response headers.

middleapi/orpc #120 · PR by dinwwwh · Merged

middleapi/orpc c3068b4b..b178e9c1

base and head as given

  • CORS support entered the server request path
  • Response headers can now be contributed through server plugins
  • Standard request handlers now depend on the plugin layer
  • The plugin layer now depends on standard request handlers
files changed
12
in a component
9
lines in components
292
components
5
public routes changed
0
schema statements
0
new dependencies
0
excluded by role
3
Based on 9 of 9 eligible changed files

Server request plugins

Added
Before
Handlers had no plugin configuration
After
Handlers initialize configured plugins

Server adapters can now install CORS policies and let procedures append response headers through configured plugins. CORS preflight requests can return before route matching.

In favour

  • In favour: CORS preflight handling bypasses route matching
  • In favour: Procedure code can append headers without constructing responses

Against

  • Against: Plugins and handlers now import each other across 9 edges
Files changed in 5 components. Dependencies shown: 2 new, 1 unchanged
unchanged · 1new · 21 component added

2 new dependencies between components — Server Plugins → Standard Adapter · Standard Adapter → Server Plugins

What else could behave differently

6 components · 22 files

These components import changed code, directly or through other files. A traced dependency is a place to review, not a confirmed runtime failure.

Reached 3

ComponentSymbolCited atFilesReached by
Standard Adapterpackages/server/src/adapters/standard/Signature changed 1 of 4 changed symbols reaching itpackages/server/src/adapters/standard/handler.ts:26-3843 direct · 1 at two steps
Trace path

Shortest component path from the changed symbol:

  1. Standard Adapter

Later steps follow file imports; they do not prove this symbol is called.

Server Pluginspackages/server/src/plugins/Added 1 of 4 changed symbols reaching itpackages/server/src/adapters/standard/handler.ts:2443 direct · 1 at two steps
Trace path

Shortest component path from the changed symbol:

  1. Standard Adapter
  2. Server Plugins

Later steps follow file imports; they do not prove this symbol is called.

packages/server/src/adapters/fetch/Signature changed 1 of 4 changed symbols reaching itpackages/server/src/adapters/standard/handler.ts:40-10951 direct · 2 at two steps · 2 at three steps
Trace path

Shortest component path from the changed symbol:

  1. Standard Adapter
  2. packages/server/src/adapters/fetch/

Later steps follow file imports; they do not prove this symbol is called.

Ranked lower 3

ComponentFilesReached by
packages/server/src/adapters/node/51 direct · 2 at two steps · 2 at three steps
packages/server/src/adapters/hono/2none direct · 1 at two steps · 1 at three steps
packages/server/src/adapters/next/2none direct · 1 at two steps · 1 at three steps

Statements 4

StandardHandlerOptions' signature changed and reached 4 files in the standard adapter. 31
packages/server/src/adapters/standard/handler.ts:26-38
StandardHandlerInterceptorOptions was added and reached 4 files in the plugins. 31
packages/server/src/adapters/standard/handler.ts:24
StandardHandler's signature changed and reached 5 files in the fetch adapter. 122
packages/server/src/adapters/standard/handler.ts:40-109
nodeHttpResponseSendStandardResponse's body changed and reached 5 files in the Node adapter. 122
packages/server/src/adapters/node/utils.ts:37-107

5 reached files belong to no component — tests, docs and config.

Routes, schema, dependencies

No public URL, no migration and no new package.

Not stated

  • 1 route was found on files whose role excludes them, so no route is claimed for them.

Inspect components, files and symbols

Component

SharedModified
packages/shared/src/

1 file · 12 lines

exports

Standard AdapterModified
packages/server/src/adapters/standard/

1 file · 104 lines

5 dependents

The standard adapter exported StandardHandlerInterceptorOptions and WellStandardHandleOptions.
OpenAPI PlaygroundModified
playgrounds/openapi/src/

2 files · 13 lines

1 dependent

Server PluginsAdded
packages/server/src/plugins/

4 files · 161 lines

1 dependent

The plugins exported CORSOptions, CORSPlugin, CompositePlugin, Plugin, ResponseHeadersPlugin, and ResponseHeadersPluginContext.
Node AdapterModified
packages/server/src/adapters/node/

1 file · 2 lines

1 shared file changed, with 12 lines added or removed.
1 Node adapter file changed, with 2 lines added or removed.
The shared static surface no longer exported Interceptable.

File

Standard Adapterpackages/server/src/adapters/standard/
packages/server/src/adapters/standard/handler.ts

+65 −39

OpenAPI Playgroundplaygrounds/openapi/src/
playgrounds/openapi/src/main.ts

+10 −0

OpenAPI Playgroundplaygrounds/openapi/src/
playgrounds/openapi/src/orpc.ts

+2 −1

Server Pluginspackages/server/src/plugins/
packages/server/src/plugins/cors.ts

+101 −0

Server Pluginspackages/server/src/plugins/
packages/server/src/plugins/response-headers.ts

+41 −0

Server Pluginspackages/server/src/plugins/
packages/server/src/plugins/base.ts

+16 −0

Server Pluginspackages/server/src/plugins/
packages/server/src/plugins/index.ts

+3 −0

Function

imports what changeddownstream of it, one mark per step

Diff

Standard Adapterpackages/server/src/adapters/standard/
packages/server/src/adapters/standard/handler.ts

2–2, 4–4, 9–9 and 13 more spans

OpenAPI Playgroundplaygrounds/openapi/src/
playgrounds/openapi/src/main.ts

6–6, 20–25, 34–36

OpenAPI Playgroundplaygrounds/openapi/src/
playgrounds/openapi/src/orpc.ts

1–1, 6–6

Server Pluginspackages/server/src/plugins/
packages/server/src/plugins/cors.ts

1–101

Server Pluginspackages/server/src/plugins/
packages/server/src/plugins/response-headers.ts

1–41

Server Pluginspackages/server/src/plugins/
packages/server/src/plugins/base.ts

1–16

Server Pluginspackages/server/src/plugins/
packages/server/src/plugins/index.ts

1–3

Analysis scope

501 → 5
  1. 501
    files at head
  2. 55
    components
  3. 5
    changed by this change

Where the new files landed

4 new files
New fileBelongs toUsed byCallsServes
packages/server/src/plugins/4 new files
Server Pluginsnew territory
Standard Adapter
packages/server/src/Standard Adapter
./plugins
5components changed
3reached, not changed
1components added/removed
3dependencies added between components
0dependencies removed between components
0files moved to another path

12 files changed, 14 claims stated. 6 components reached in total.

naming: “model

narrative: “model

analyzer 0.2.0, config v1.9.0-phase8

Every line above is derived from c3068b4b..b178e9c1 and nothing else.