ts-typed-api 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,4 +32,4 @@ export type HonoTypedContext<TDef extends ApiDefinitionSchema, TDomain extends k
32
32
  };
33
33
  export declare function registerHonoRouteHandlers<TDef extends ApiDefinitionSchema, TBindings extends Env = Env, TVariables extends Record<string, never> = Record<string, never>, TPath extends string = "/">(app: Hono<TBindings, TVariables, TPath>, apiDefinition: TDef, routeHandlers: Array<SpecificRouteHandler<TDef>>, middlewares?: EndpointMiddleware<TDef>[]): void;
34
34
  export declare function RegisterHonoHandlers<TDef extends ApiDefinitionSchema, Ctx extends Record<string, any> = Record<string, any>, TBindings extends Env = Env, TVariables extends Record<string, never> = Record<string, never>, TPath extends string = "/">(app: Hono<TBindings, TVariables, TPath>, apiDefinition: TDef, objectHandlers: ObjectHandlers<TDef, Ctx>, middlewares?: AnyMiddleware<TDef>[]): void;
35
- export declare function CreateTypedHonoHandlerWithContext<Ctx extends Record<string, any>>(): <TDef extends ApiDefinitionSchema>(app: Hono, apiDefinition: TDef, objectHandlers: ObjectHandlers<TDef, Ctx>, middlewares?: AnyMiddleware<TDef>[]) => void;
35
+ export declare function CreateTypedHonoHandlerWithContext<Ctx extends Record<string, any>>(): <TDef extends ApiDefinitionSchema, TBindings extends Env = Env, TVariables extends Record<string, never> = Record<string, never>, TPath extends string = "/">(app: Hono<TBindings, TVariables, TPath>, apiDefinition: TDef, objectHandlers: ObjectHandlers<TDef, Ctx>, middlewares?: AnyMiddleware<TDef>[]) => void;
@@ -477,7 +477,7 @@ function RegisterHonoHandlers(app, apiDefinition, objectHandlers, middlewares) {
477
477
  const handlerArray = transformObjectHandlersToArray(objectHandlers);
478
478
  // Convert AnyMiddleware to EndpointMiddleware by checking function arity
479
479
  const endpointMiddlewares = middlewares?.map(middleware => {
480
- if (middleware.length === 4) {
480
+ if (middleware && middleware.length === 4) {
481
481
  return middleware;
482
482
  }
483
483
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-typed-api",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "A lightweight, type-safe RPC library for TypeScript with Zod validation",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -575,7 +575,7 @@ export function RegisterHonoHandlers<
575
575
 
576
576
  // Convert AnyMiddleware to EndpointMiddleware by checking function arity
577
577
  const endpointMiddlewares: EndpointMiddleware<TDef>[] = middlewares?.map(middleware => {
578
- if (middleware.length === 4) {
578
+ if (middleware && middleware.length === 4) {
579
579
  return middleware as EndpointMiddleware<TDef>;
580
580
  } else {
581
581
  return ((req, res, next) => {
@@ -588,8 +588,13 @@ export function RegisterHonoHandlers<
588
588
  }
589
589
 
590
590
  export function CreateTypedHonoHandlerWithContext<Ctx extends Record<string, any>>() {
591
- return function <TDef extends ApiDefinitionSchema>(
592
- app: Hono,
591
+ return function <
592
+ TDef extends ApiDefinitionSchema,
593
+ TBindings extends Env = Env,
594
+ TVariables extends Record<string, never> = Record<string, never>,
595
+ TPath extends string = "/"
596
+ >(
597
+ app: Hono<TBindings, TVariables, TPath>,
593
598
  apiDefinition: TDef,
594
599
  objectHandlers: ObjectHandlers<TDef, Ctx>,
595
600
  middlewares?: AnyMiddleware<TDef>[]