Releases: arkstack-hq/clear-router
Releases · arkstack-hq/clear-router
Release list
2.5.7
What's Changed
- enhance plugin system to support async setup and binding resolution
Full Changelog: 2.5.6...2.5.7
2.5.6
Added
- Added a core plugin API for extending Clear Router from external packages.
- Added
definePlugin(...)fromclear-router/core. - Added
Router.use(plugin, options)for installing plugins on any router adapter. - Added plugin context helpers:
bind(token, value)containerconfigure(options)configureDefaults(options)options
Container Binding Plugins
Plugins can now register container bindings directly:
import { definePlugin } from 'clear-router/core'
class AuditService {}
export const auditPlugin = definePlugin({
name: 'audit',
setup({ bind }) {
bind(AuditService, () => new AuditService())
},
})Then install on any adapter:
Router.use(auditPlugin)Plugins can also accept options:
Router.use(auditPlugin, { label: 'app' })Improved
- Named plugins are installed once per process to avoid duplicate setup.
- Container binding documentation now includes plugin authoring examples.
- API docs now include
Router.use(plugin, options).
Tests
- Added coverage proving plugins can register container bindings and decorated controllers can resolve those plugin-provided services.
Full Changelog: 2.5.5...2.5.6
2.5.5
Added
- Added optional container binding support for controller method arguments.
- Added
clear-router/decoratorswith:@Bind(...)Container.bind(...)Container.unbind(...)Container.clear()
- Added
clear-router/decorators/setup, a one-import setup entry that:- imports
reflect-metadata - enables container binding defaults
- enables
autoDiscover
- imports
- Added optional
reflect-metadatapeer dependency and dev dependency. - Added support for tokenless
@Bind()when legacydesign:paramtypesmetadata is available. - Added support for class-level binding:
@Bind() class UsersController {}
- Added support for TypeScript 5.2+ standard decorator metadata with explicit bind tokens.
- Added auto-discovery for unknown constructable classes when
container.autoDiscoveris enabled. - Added new
Router.configure({ container })options:container.enabledcontainer.autoDiscover
- Added container binding documentation page.
Improved
- Route handler invocation now uses a shared binding resolver across Express, Fastify, H3, Hono, and Koa.
- Decorated handlers gracefully fall back to the existing
(ctx, clearRequest)signature when binding is disabled or resolution fails. - Adapter setup now passes binding metadata through each framework consistently.
Tests
- Added coverage for:
- explicit
@Bind(Request, Response, Service) - tokenless
@Bind()withreflect-metadata - class-level
@Bind() - TS 5.2+ standard decorator metadata
- setup-entry side effects
- explicit container bindings
- disabled binding fallback behavior.
- explicit
Full Changelog: 2.5.0...2.5.5
2.5.0
What Changed
- Introduced a new Koa router in
src/koa/router.tswith support for various HTTP methods and middleware. - Added type definitions for Koa in
types/koa.ts. - Updated existing tests to use
parasitofor HTTP requests instead ofsupertest. - Implemented tests for Koa router functionality in
tests/koa.test.ts, covering basic routing, body parsing, and method overrides. - Enhanced the core router to handle OPTIONS requests and set appropriate headers.
- Updated
tsdown.config.tsto include Koa in the build process.
Full Changelog: 2.4.0...2.5.0
2.4.0
Added
- Added direct route return support across Express, Fastify, Hono, and h3 adapters.
- Route handlers can now return strings, numbers, booleans, objects,
Response, h3HTTPResponse, and framework-native response objects directly. - Added automatic response normalization for returned values:
- HTML-like strings return
text/html - API/XHR-style requests return plain text for string bodies
- Objects return JSON
POSTdirect returns default to201- Other direct returns default to
200
- HTML-like strings return
Improved
- Express handlers no longer need to manually call
res.setHeader(...).status(...).send(...)for simple direct responses. - Existing response APIs like
res.send(),res.json(),reply.send(), HonoResponse, h3 responses, and resora responses remain supported. - Added shared response handling logic across adapters for more consistent behavior.
Tests
- Added adapter coverage for direct primitive, object, and
Responsereturns. - Verified Express, Fastify, Hono, h3, ESM, and TypeScript test suites.
Full Changelog: 2.3.2...2.4.0
2.3.2
What's Changed
- implement router state management across different router classes
Full Changelog: 2.3.0...2.3.2
2.3.0
What's Changed
- Add Fastify, H3, and Hono support with comprehensive routing capabilities
- Implement Fastify router with method overrides, request body access, and middleware support.
- Introduce H3 router with similar features, ensuring compatibility with H3's context and request handling.
- Add Hono router, providing a routing system with support for middleware and API resource binding.
- Create documentation for using clear-router with Fastify, H3, and Hono, including quick start guides and usage examples.
- Develop tests for Fastify and Hono routers to ensure functionality and reliability.
Full Changelog: 2.2.0...2.3.0
2.2.0
What's Changed
- Moved core routing logic to a new CoreRouter class in src/core/router.ts.
- Updated H3 router to extend CoreRouter, simplifying route management and middleware handling.
- Added adapter authoring guide to docs/adapters.md for creating new framework adapters.
- Adjusted TypeScript configuration to include core module paths.
- Updated tests and index exports to reflect new structure.
Full Changelog: 2.1.12...2.2.0
2.1.12
What's Changed
- Implemented ensureRequestBodyAccessor to provide a getBody method for accessing request body in Express and H3 routers.
- Updated Router class in both Express and H3 to utilize getBody method for body retrieval.
- Enhanced tests to verify the presence and functionality of getBody in request handlers.
- Added documentation for the new features and usage examples.
Full Changelog: 2.1.11...2.1.12
2.1.11
What's Changed
- feat: add HTTP method override support with configurable body and header keys
- refactor: update allRoutes method signatures for clarity and consistency
Full Changelog: 2.1.9...2.1.11