Skip to content

Releases: arkstack-hq/clear-router

2.5.7

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 08 May 13:38

What's Changed

  • enhance plugin system to support async setup and binding resolution

Full Changelog: 2.5.6...2.5.7

2.5.6

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 08 May 12:33

Added

  • Added a core plugin API for extending Clear Router from external packages.
  • Added definePlugin(...) from clear-router/core.
  • Added Router.use(plugin, options) for installing plugins on any router adapter.
  • Added plugin context helpers:
    • bind(token, value)
    • container
    • configure(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

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 08 May 11:59

Added

  • Added optional container binding support for controller method arguments.
  • Added clear-router/decorators with:
    • @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
  • Added optional reflect-metadata peer dependency and dev dependency.
  • Added support for tokenless @Bind() when legacy design:paramtypes metadata 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.autoDiscover is enabled.
  • Added new Router.configure({ container }) options:
    • container.enabled
    • container.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() with reflect-metadata
    • class-level @Bind()
    • TS 5.2+ standard decorator metadata
    • setup-entry side effects
    • explicit container bindings
    • disabled binding fallback behavior.

Full Changelog: 2.5.0...2.5.5

2.5.0

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 06 May 23:52

What Changed

  • Introduced a new Koa router in src/koa/router.ts with support for various HTTP methods and middleware.
  • Added type definitions for Koa in types/koa.ts.
  • Updated existing tests to use parasito for HTTP requests instead of supertest.
  • 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.ts to include Koa in the build process.

Full Changelog: 2.4.0...2.5.0

2.4.0

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 06 May 22:52

Added

  • Added direct route return support across Express, Fastify, Hono, and h3 adapters.
  • Route handlers can now return strings, numbers, booleans, objects, Response, h3 HTTPResponse, 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
    • POST direct returns default to 201
    • Other direct returns default to 200

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(), Hono Response, 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 Response returns.
  • Verified Express, Fastify, Hono, h3, ESM, and TypeScript test suites.

Full Changelog: 2.3.2...2.4.0

2.3.2

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 19 Mar 14:55

What's Changed

  • implement router state management across different router classes

Full Changelog: 2.3.0...2.3.2

2.3.0

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 19 Mar 07:27

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

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 18 Mar 22:30

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

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 18 Mar 19:20

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

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 17 Mar 01:59

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