Skip to content

feat: DRY adapter base, add Next.js/Hono/Fastify adapters, migrate tests to vitest#97

Open
Sarita-Joshi wants to merge 2 commits into
trycatchal:masterfrom
Sarita-Joshi:feat/dry-adapters-and-tests
Open

feat: DRY adapter base, add Next.js/Hono/Fastify adapters, migrate tests to vitest#97
Sarita-Joshi wants to merge 2 commits into
trycatchal:masterfrom
Sarita-Joshi:feat/dry-adapters-and-tests

Conversation

@Sarita-Joshi
Copy link
Copy Markdown
Contributor

  • Extract shared HandlerConfig type, defineHandler, and prepareHipthrustable into src/adapter.ts so all framework adapters reuse the same base
  • Add Next.js App Router adapter (src/next.ts) with gatherContext for async pre-lifecycle work
  • Add Hono adapter (src/hono.ts)
  • Add Fastify adapter (src/fastify.ts)
  • Slim Express adapter to use shared base
  • Fix pre-existing bug: transformThrowPossiblyAsync now catches sync throws from async-capable functions
  • Migrate test/index.test.ts from mocha/chai to vitest, fix nested it() bug
  • Add comprehensive test suites: adapter, lifecycle, HipError, type-safety, and per-adapter integration tests (131 tests total)
  • Add hello-world examples for Express, Hono, Fastify, and Next.js
  • Add hono, fastify, next as optional peer dependencies

Removes the @hapi/boom dependency entirely and replaces it with a
lightweight HipError class defined in core.ts. This gives hipthrusts
its own error type with no external dependencies, making it simpler
for consumers (no need to import or know about boom).

HipError has statusCode, message, and a static isHipError() type guard.
Adapters catch HipError directly instead of checking Boom.isBoom().

BREAKING CHANGE: Consumers that caught Boom errors from hipthrusts
should now catch HipError instead. The .output property is preserved
for backwards compatibility with existing adapter code.
…sts to vitest

- Extract shared HandlerConfig type, defineHandler, and prepareHipthrustable
  into src/adapter.ts so all framework adapters reuse the same base
- Add Next.js App Router adapter (src/next.ts)
- Add Hono adapter (src/hono.ts)
- Add Fastify adapter (src/fastify.ts)
- Slim Express adapter to use shared base
- Fix pre-existing bug: transformThrowPossiblyAsync now catches sync throws
- Migrate test/index.test.ts from mocha/chai to vitest
- Fix pre-existing nested it() bug in type error test case
- Add comprehensive test suites (131 tests total)
- Add hello-world examples for Express, Hono, Fastify, and Next.js
- Add hono, fastify, next as optional peer dependencies
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.

1 participant