Skip to content

Address phase 6 review: fix packaging, types, and Fastify behavior#1513

Merged
ricardo-devis-agullo merged 10 commits into
masterfrom
refactor/http-server-adapter-phase-6
Jul 9, 2026
Merged

Address phase 6 review: fix packaging, types, and Fastify behavior#1513
ricardo-devis-agullo merged 10 commits into
masterfrom
refactor/http-server-adapter-phase-6

Conversation

@ricardo-devis-agullo

@ricardo-devis-agullo ricardo-devis-agullo commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Adapter implementation:

  • Implement HttpServerAdapter interface against Fastify
  • Body parsing with qs urlencoded semantics
  • Cookie support
  • Multipart uploads normalized to OC upload file shape
  • Request timing, logging, local error handling
  • Strong ETag/304 support
  • HEAD/OPTIONS parity with Express
  • Re-export neutral HTTP adapter types from oc package root

Package & dependencies:

  • Fix package entry points (tsconfig rootDir, exclude dist/test from published files)
  • Move oc to peerDependency (>=0.50.56) and devDependency to avoid pulling Express into adapter installs

Neutral types:

  • Replace Express/Multer type aliases with structural CookieOptions/UploadedFile to avoid external type dependency leakage

Behavior fixes:

  • Cookies: translate Express maxAge (ms→s) and default Path=/; fail on signed cookies
  • Listen: default host to 0.0.0.0, accept host option, report invalid ports via callback
  • Body: add gzip/deflate/brotli inflation via preParsing with receivedEncodedLength
  • Logging: guard skip function against missing res.conf in adapter and core middleware
  • Multipart: throw LIMIT_FIELD_VALUE-style 413 on field truncation
  • OPTIONS: scope Allow header to matching routes when possible
  • Fallthrough: 404 only on empty handler arrays
  • Response: track hasSent immediately to avoid false fallthroughs; remove default end() content-type

Tests:

  • Adapter tests: ETag/304, OPTIONS, urlencoded qs, cookies, wildcard params, connect middleware, streaming, multipart, listen host, invalid port, scoped Allow
  • Registry integration tests: non-local publish with basic auth, temp file-backed storage, static streaming, batch POST

Docs:

  • README documenting opt-in contract and known Express/Fastify differences

ricardo-devis-agullo and others added 3 commits July 7, 2026 16:59
Adds packages/oc-fastify-server-adapter implementing the HttpServerAdapter
interface against Fastify: body parsing with qs urlencoded semantics,
cookies, multipart uploads normalized to the OC upload file shape, request
timing, logging, local error handling, strong ETag/304 support, and
HEAD/OPTIONS parity with Express.

Re-exports the neutral HTTP adapter types from the oc package root so the
external adapter can compile against the public package surface.

Includes adapter-level parity tests (ETag/304, OPTIONS, urlencoded qs,
cookies, wildcard params, connect middleware, streaming, multipart) and
registry-level opt-in smoke/parity tests exercising the adapter through
Registry({ server: { adapter } }).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fixes blocking issues and should-fix items from the phase 6 review:
- Package: fix broken entry points (tsconfig rootDir, files exclude dist/test)
- Deps: move oc to peerDependency (>=0.50.56) and devDependency
- Types: replace Express/Multer type aliases with neutral CookieOptions/UploadedFile
- Cookies: translate Express maxAge (ms→s) and default Path=/; fail on signed
- Listen: default host to 0.0.0.0, accept host option, catch invalid ports via callback
- Body: add gzip/deflate/brotli inflation via preParsing, set receivedEncodedLength
- Logging: guard skip against missing res.conf in adapter and core middleware
- Multipart: throw LIMIT_FIELD_VALUE on field truncation (match multer)
- OPTIONS: scope Allow header to matching routes when possible
- Fallthrough: 404 only on empty handler arrays; document send requirement
- Response: track hasSent immediately to avoid false fallthroughs; remove default end() content-type
- Tests: add adapter tests for cookie semantics, compressed JSON, listen host, invalid port, scoped Allow, empty-handler 404
- Integration: add non-local publish/auth/static/batch smoke tests with temp file storage
- Docs: add README documenting opt-in contract and Fastify differences

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Keep compile-time HTTP server adapter types self-contained so the package can build before oc emits dist/index.d.ts in workspace CI.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a new Fastify-based HttpServerAdapter implementation for the OC registry and updates OC’s neutral HTTP types and packaging so adapters can depend on OC without pulling in Express-specific types.

Changes:

  • Introduces oc-fastify-server-adapter with Fastify routing, body parsing (qs urlencoded), cookies, multipart uploads, ETag/304 handling, and OPTIONS/HEAD parity.
  • Replaces Express/Multer type aliases in OC with structural CookieOptions and UploadedFile, and re-exports neutral adapter types from the oc package root.
  • Adds adapter-focused tests (unit + registry integration) and updates repo tooling/config to include the new package.

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/oc/src/registry/middleware/index.ts Guards logging skip function when res.conf is absent.
packages/oc/src/registry/domain/validators/uploaded-package.ts Switches validator typing from Multer to neutral UploadedFile.
packages/oc/src/registry/domain/http-server/types.ts Introduces structural CookieOptions/UploadedFile and keeps neutral HTTP adapter interfaces centralized.
packages/oc/src/registry/domain/extract-package.ts Updates extract-package typing to neutral UploadedFile.
packages/oc/src/index.ts Re-exports neutral HTTP adapter types from the OC package root.
packages/oc-fastify-server-adapter/tsconfig.test.json Adds a dedicated TS config to emit integration test code to dist/test.
packages/oc-fastify-server-adapter/tsconfig.json Adds TypeScript build configuration for the new adapter package.
packages/oc-fastify-server-adapter/test/registry-node.ts Adds integration tests that run an OC registry using the Fastify adapter.
packages/oc-fastify-server-adapter/test/index.test.ts Adds adapter unit tests for ETags, OPTIONS/Allow, cookies, urlencoded parsing, streaming, multipart, and listen behavior.
packages/oc-fastify-server-adapter/src/index.ts Implements the Fastify HttpServerAdapter (routing, middleware bridging, cookie/body/multipart support).
packages/oc-fastify-server-adapter/README.md Documents adapter usage and behavioral differences vs Express.
packages/oc-fastify-server-adapter/package.json Defines adapter package metadata, build/lint/test scripts, and dependencies/peerDependencies.
package-lock.json Locks new dependencies introduced by the adapter package.
biome.json Includes the new adapter package in Biome’s formatting/linting scope.
.gitignore Ignores the adapter’s dist/ output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/oc-fastify-server-adapter/src/index.ts Outdated
Comment thread packages/oc-fastify-server-adapter/src/index.ts Outdated
ricardo-devis-agullo and others added 4 commits July 7, 2026 18:45
The adapter now uses self-contained structural types and does not need oc for package builds. Keep oc only as a peer dependency to document the supported host package range.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The adapter has no compile-time or runtime dependency on oc and is consumed structurally by the host package.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ricardo-devis-agullo

Copy link
Copy Markdown
Collaborator Author

@copilot build failed. check why and try to fix

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@copilot build failed. check why and try to fix

The CI failure was in oc-fastify-server-adapter#test-silent. The test imported HttpServerAdapter from 'oc', but oc was no longer in the adapter's devDependencies.

Fixed in commit Fix CI: export HttpServerAdapter from adapter and import from local source in tests:

  • Exported HttpServerAdapter type from the adapter's src/index.ts
  • Updated test/index.test.ts to import it from '../src' instead of 'oc'

All 9 tests now pass locally and the build is clean.

@ricardo-devis-agullo
ricardo-devis-agullo merged commit e3c9617 into master Jul 9, 2026
3 checks passed
@ricardo-devis-agullo
ricardo-devis-agullo deleted the refactor/http-server-adapter-phase-6 branch July 9, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants