ts-typed-api 0.2.8 → 0.2.9
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.
- package/dist/hono-only.d.ts +4 -1
- package/dist/hono-only.js +7 -5
- package/package.json +1 -1
- package/src/hono-only.ts +20 -1
package/dist/hono-only.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { ApiDefinitionSchema } from './definition';
|
|
2
|
+
import type { TypedRequest, TypedResponse } from './router';
|
|
1
3
|
export { CreateApiDefinition, CreateResponses } from './definition';
|
|
2
4
|
export { z as ZodSchema } from 'zod';
|
|
3
|
-
export { EndpointMiddleware, EndpointMiddlewareCtx
|
|
5
|
+
export { EndpointMiddleware, EndpointMiddlewareCtx } from './object-handlers';
|
|
6
|
+
export declare function createTypedHandler<TDef extends ApiDefinitionSchema, TDomain extends keyof TDef['endpoints'], TRouteKey extends keyof TDef['endpoints'][TDomain], Ctx extends Record<string, any> = Record<string, any>>(handler: (req: TypedRequest<TDef, TDomain, TRouteKey, any, any, any, any, Ctx>, res: TypedResponse<TDef, TDomain, TRouteKey>) => Promise<void> | void): (req: TypedRequest<TDef, TDomain, TRouteKey, any, any, any, any, Ctx>, res: TypedResponse<TDef, TDomain, TRouteKey>) => Promise<void> | void;
|
|
4
7
|
export { RegisterHonoHandlers, CreateTypedHonoHandlerWithContext } from './hono-cloudflare-workers';
|
|
5
8
|
export type { ApiDefinitionSchema, RouteSchema, UnifiedError, FileUploadConfig, HttpSuccessStatusCode, HttpClientErrorStatusCode, HttpServerErrorStatusCode, AllowedInputStatusCode, AllowedResponseStatusCode } from './definition';
|
|
6
9
|
export type { HonoFile, HonoFileType, HonoTypedContext } from './hono-cloudflare-workers';
|
package/dist/hono-only.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CreateTypedHonoHandlerWithContext = exports.RegisterHonoHandlers = exports.
|
|
4
|
-
|
|
5
|
-
// Excludes Express dependencies like multer, busboy, etc.
|
|
3
|
+
exports.CreateTypedHonoHandlerWithContext = exports.RegisterHonoHandlers = exports.ZodSchema = exports.CreateResponses = exports.CreateApiDefinition = void 0;
|
|
4
|
+
exports.createTypedHandler = createTypedHandler;
|
|
6
5
|
var definition_1 = require("./definition");
|
|
7
6
|
Object.defineProperty(exports, "CreateApiDefinition", { enumerable: true, get: function () { return definition_1.CreateApiDefinition; } });
|
|
8
7
|
Object.defineProperty(exports, "CreateResponses", { enumerable: true, get: function () { return definition_1.CreateResponses; } });
|
|
9
8
|
var zod_1 = require("zod");
|
|
10
9
|
Object.defineProperty(exports, "ZodSchema", { enumerable: true, get: function () { return zod_1.z; } });
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// Helper function to create typed handlers with proper type inference
|
|
11
|
+
// Defined locally to avoid Express dependencies in Hono-only bundle
|
|
12
|
+
function createTypedHandler(handler) {
|
|
13
|
+
return handler;
|
|
14
|
+
}
|
|
13
15
|
// Hono adapter for Cloudflare Workers
|
|
14
16
|
var hono_cloudflare_workers_1 = require("./hono-cloudflare-workers");
|
|
15
17
|
Object.defineProperty(exports, "RegisterHonoHandlers", { enumerable: true, get: function () { return hono_cloudflare_workers_1.RegisterHonoHandlers; } });
|
package/package.json
CHANGED
package/src/hono-only.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
// Hono-only exports - for Cloudflare Workers and other Hono environments
|
|
2
2
|
// Excludes Express dependencies like multer, busboy, etc.
|
|
3
|
+
import type { ApiDefinitionSchema } from './definition';
|
|
4
|
+
import type { TypedRequest, TypedResponse } from './router';
|
|
5
|
+
|
|
3
6
|
export { CreateApiDefinition, CreateResponses } from './definition';
|
|
4
7
|
export { z as ZodSchema } from 'zod';
|
|
5
|
-
export { EndpointMiddleware, EndpointMiddlewareCtx
|
|
8
|
+
export { EndpointMiddleware, EndpointMiddlewareCtx } from './object-handlers'
|
|
9
|
+
|
|
10
|
+
// Helper function to create typed handlers with proper type inference
|
|
11
|
+
// Defined locally to avoid Express dependencies in Hono-only bundle
|
|
12
|
+
export function createTypedHandler<
|
|
13
|
+
TDef extends ApiDefinitionSchema,
|
|
14
|
+
TDomain extends keyof TDef['endpoints'],
|
|
15
|
+
TRouteKey extends keyof TDef['endpoints'][TDomain],
|
|
16
|
+
Ctx extends Record<string, any> = Record<string, any>
|
|
17
|
+
>(
|
|
18
|
+
handler: (
|
|
19
|
+
req: TypedRequest<TDef, TDomain, TRouteKey, any, any, any, any, Ctx>,
|
|
20
|
+
res: TypedResponse<TDef, TDomain, TRouteKey>
|
|
21
|
+
) => Promise<void> | void
|
|
22
|
+
) {
|
|
23
|
+
return handler;
|
|
24
|
+
}
|
|
6
25
|
|
|
7
26
|
// Hono adapter for Cloudflare Workers
|
|
8
27
|
export { RegisterHonoHandlers, CreateTypedHonoHandlerWithContext } from './hono-cloudflare-workers';
|