@taserjs/router 0.0.1 → 0.0.2
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/cjs/index.cjs +6 -0
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/middleware/auth.cjs +1 -1
- package/dist/cjs/middleware/auth.cjs.map +1 -1
- package/dist/cjs/reply.cjs +20 -0
- package/dist/cjs/reply.d.cts +2 -0
- package/dist/cjs/stream.cjs +32 -0
- package/dist/cjs/stream.d.cts +1 -0
- package/dist/cjs/types/type-utils.d.cts +0 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/middleware/auth.js +2 -2
- package/dist/esm/middleware/auth.js.map +1 -1
- package/dist/esm/reply.d.ts +2 -0
- package/dist/esm/reply.js +2 -0
- package/dist/esm/stream.d.ts +1 -0
- package/dist/esm/stream.js +2 -0
- package/dist/esm/types/type-utils.d.ts +0 -1
- package/package.json +23 -3
- package/src/index.ts +1 -0
- package/src/middleware/auth.ts +2 -2
- package/src/reply.ts +15 -0
- package/src/stream.ts +7 -0
- package/src/types/type-utils.ts +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -34,6 +34,12 @@ Object.defineProperty(exports, "reply", {
|
|
|
34
34
|
return _taserjs_router_utils.reply;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
+
Object.defineProperty(exports, "stream", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function() {
|
|
40
|
+
return _taserjs_router_utils.stream;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
37
43
|
Object.defineProperty(exports, "validationErrorSchema", {
|
|
38
44
|
enumerable: true,
|
|
39
45
|
get: function() {
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { RouterRegister } from './register.js';
|
|
2
2
|
export type { InferInput, InferOutput, Method, PathParams, ReturnsMap, RoutePath, Schema, Simplify, } from './types/index.js';
|
|
3
3
|
export type { ContextDefinition, CreateContextArgs, CreateTaserAppOptions, InferAppContext, InferAppManifest, OnErrorOptions, RouteManifestShape, TaserHandler, } from './types/app.js';
|
|
4
|
-
export { isReplyResult, reply, ValidationError, validationErrorSchema, } from '@taserjs/router-utils';
|
|
4
|
+
export { isReplyResult, reply, stream, ValidationError, validationErrorSchema, } from '@taserjs/router-utils';
|
|
5
5
|
export type { ReplyBodyKind, ReplyOf, ResponseValidationFailureHandler, SuccessReplyData, SuccessStatusCode, } from '@taserjs/router-utils';
|
|
6
6
|
export { createAnyRoute, createAllRoute } from './factories.js';
|
|
7
7
|
export { createTaserApp, TaserRouter } from './taser-router.js';
|
|
@@ -17,7 +17,7 @@ function createAuthMiddleware(payloadSchema, honoMw) {
|
|
|
17
17
|
try {
|
|
18
18
|
return next({ state: { jwtPayload: await (0, _taserjs_router_utils.validateSchema)(payloadSchema, payload) } });
|
|
19
19
|
} catch (error) {
|
|
20
|
-
if (error instanceof _taserjs_router_utils.ValidationError) return
|
|
20
|
+
if (error instanceof _taserjs_router_utils.ValidationError) return _taserjs_router_utils.reply.forbidden({
|
|
21
21
|
error: "Forbidden",
|
|
22
22
|
issues: error.issues
|
|
23
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.cjs","names":[],"sources":["../../../src/middleware/auth.ts"],"sourcesContent":["import { createTaserCompatHandler } from '@taserjs/router-core'\nimport { validateSchema, ValidationError } from '@taserjs/router-utils'\nimport type { MiddlewareHandler } from 'hono'\n\nimport { defineMiddleware } from '../define/middleware.js'\nimport type { InferOutput, Schema } from '../types/schema.js'\nimport type { MiddlewareReturnFromParts, MiddlewareUnit } from '../types/units.js'\n\nexport function wrapHonoMiddleware<F extends (...args: never[]) => MiddlewareHandler>(\n honoFactory: F,\n): (...args: Parameters<F>) => MiddlewareUnit<MiddlewareReturnFromParts<unknown, unknown, unknown, {}>> {\n return (...args) => defineMiddleware(honoFactory(...args))\n}\n\nexport type JwtPayloadState<TPayload> = {\n jwtPayload: TPayload\n}\n\nexport type AuthMiddlewareUnit<TPayload> = MiddlewareUnit<\n MiddlewareReturnFromParts<unknown, unknown, unknown, JwtPayloadState<TPayload>>\n>\n\nfunction asJwtPayloadStateSchema<TPayload>(\n payloadSchema: Schema<TPayload>,\n): Schema<JwtPayloadState<InferOutput<Schema<TPayload>>>> {\n return payloadSchema as unknown as Schema<JwtPayloadState<InferOutput<Schema<TPayload>>>>\n}\n\nexport function createAuthMiddleware<TPayload>(\n payloadSchema: Schema<TPayload>,\n honoMw: MiddlewareHandler,\n): AuthMiddlewareUnit<InferOutput<Schema<TPayload>>> {\n return defineMiddleware({\n state: asJwtPayloadStateSchema(payloadSchema),\n handler: (ctx, next) => {\n return createTaserCompatHandler(honoMw)(ctx, async () => {\n const payload = (ctx as unknown as { var: { jwtPayload?: unknown } }).var.jwtPayload\n try {\n const validated = await validateSchema(payloadSchema, payload)\n return next({ state: { jwtPayload: validated } })\n }\n catch (error) {\n if (error instanceof ValidationError) {\n return
|
|
1
|
+
{"version":3,"file":"auth.cjs","names":[],"sources":["../../../src/middleware/auth.ts"],"sourcesContent":["import { createTaserCompatHandler } from '@taserjs/router-core'\nimport { reply, validateSchema, ValidationError } from '@taserjs/router-utils'\nimport type { MiddlewareHandler } from 'hono'\n\nimport { defineMiddleware } from '../define/middleware.js'\nimport type { InferOutput, Schema } from '../types/schema.js'\nimport type { MiddlewareReturnFromParts, MiddlewareUnit } from '../types/units.js'\n\nexport function wrapHonoMiddleware<F extends (...args: never[]) => MiddlewareHandler>(\n honoFactory: F,\n): (...args: Parameters<F>) => MiddlewareUnit<MiddlewareReturnFromParts<unknown, unknown, unknown, {}>> {\n return (...args) => defineMiddleware(honoFactory(...args))\n}\n\nexport type JwtPayloadState<TPayload> = {\n jwtPayload: TPayload\n}\n\nexport type AuthMiddlewareUnit<TPayload> = MiddlewareUnit<\n MiddlewareReturnFromParts<unknown, unknown, unknown, JwtPayloadState<TPayload>>\n>\n\nfunction asJwtPayloadStateSchema<TPayload>(\n payloadSchema: Schema<TPayload>,\n): Schema<JwtPayloadState<InferOutput<Schema<TPayload>>>> {\n return payloadSchema as unknown as Schema<JwtPayloadState<InferOutput<Schema<TPayload>>>>\n}\n\nexport function createAuthMiddleware<TPayload>(\n payloadSchema: Schema<TPayload>,\n honoMw: MiddlewareHandler,\n): AuthMiddlewareUnit<InferOutput<Schema<TPayload>>> {\n return defineMiddleware({\n state: asJwtPayloadStateSchema(payloadSchema),\n handler: (ctx, next) => {\n return createTaserCompatHandler(honoMw)(ctx, async () => {\n const payload = (ctx as unknown as { var: { jwtPayload?: unknown } }).var.jwtPayload\n try {\n const validated = await validateSchema(payloadSchema, payload)\n return next({ state: { jwtPayload: validated } })\n }\n catch (error) {\n if (error instanceof ValidationError) {\n return reply.forbidden({ error: 'Forbidden', issues: error.issues })\n }\n throw error\n }\n })\n },\n })\n}\n"],"mappings":";;;;AAQA,SAAgB,mBACd,aACsG;CACtG,QAAQ,GAAG,SAAS,mBAAA,iBAAiB,YAAY,GAAG,IAAI,CAAC;AAC3D;AAUA,SAAS,wBACP,eACwD;CACxD,OAAO;AACT;AAEA,SAAgB,qBACd,eACA,QACmD;CACnD,OAAO,mBAAA,iBAAiB;EACtB,OAAO,wBAAwB,aAAa;EAC5C,UAAU,KAAK,SAAS;GACtB,QAAA,GAAA,qBAAA,yBAAA,CAAgC,MAAM,CAAC,CAAC,KAAK,YAAY;IACvD,MAAM,UAAW,IAAqD,IAAI;IAC1E,IAAI;KAEF,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,OAAA,GAAA,sBAAA,eAAA,CADI,eAAe,OAAO,EAChB,EAAE,CAAC;IAClD,SACO,OAAO;KACZ,IAAI,iBAAiB,sBAAA,iBACnB,OAAO,sBAAA,MAAM,UAAU;MAAE,OAAO;MAAa,QAAQ,MAAM;KAAO,CAAC;KAErE,MAAM;IACR;GACF,CAAC;EACH;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _taserjs_router_utils_reply = require("@taserjs/router-utils/reply");
|
|
3
|
+
Object.defineProperty(exports, "errorReply", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _taserjs_router_utils_reply.errorReply;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(exports, "reply", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return _taserjs_router_utils_reply.reply;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "successReply", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function() {
|
|
18
|
+
return _taserjs_router_utils_reply.successReply;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _taserjs_router_utils = require("@taserjs/router-utils");
|
|
3
|
+
Object.defineProperty(exports, "blob", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _taserjs_router_utils.blob;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(exports, "buffer", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return _taserjs_router_utils.buffer;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "file", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function() {
|
|
18
|
+
return _taserjs_router_utils.file;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "pipe", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return _taserjs_router_utils.pipe;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "stream", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function() {
|
|
30
|
+
return _taserjs_router_utils.stream;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { blob, buffer, file, pipe, stream, } from '@taserjs/router-utils';
|
|
@@ -45,7 +45,6 @@ export type RuntimeContextFields<TNative = unknown> = {
|
|
|
45
45
|
url: URL;
|
|
46
46
|
headers: import('@taserjs/router-core').TaserHeaders;
|
|
47
47
|
cookies: import('@taserjs/router-core').TaserCookieJar;
|
|
48
|
-
reply: typeof import('@taserjs/router-utils').reply;
|
|
49
48
|
var: Record<string, unknown>;
|
|
50
49
|
native?: TNative;
|
|
51
50
|
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { RouterRegister } from './register.js';
|
|
2
2
|
export type { InferInput, InferOutput, Method, PathParams, ReturnsMap, RoutePath, Schema, Simplify, } from './types/index.js';
|
|
3
3
|
export type { ContextDefinition, CreateContextArgs, CreateTaserAppOptions, InferAppContext, InferAppManifest, OnErrorOptions, RouteManifestShape, TaserHandler, } from './types/app.js';
|
|
4
|
-
export { isReplyResult, reply, ValidationError, validationErrorSchema, } from '@taserjs/router-utils';
|
|
4
|
+
export { isReplyResult, reply, stream, ValidationError, validationErrorSchema, } from '@taserjs/router-utils';
|
|
5
5
|
export type { ReplyBodyKind, ReplyOf, ResponseValidationFailureHandler, SuccessReplyData, SuccessStatusCode, } from '@taserjs/router-utils';
|
|
6
6
|
export { createAnyRoute, createAllRoute } from './factories.js';
|
|
7
7
|
export { createTaserApp, TaserRouter } from './taser-router.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -4,5 +4,5 @@ import { defineMiddleware } from "./define/middleware.js";
|
|
|
4
4
|
import { TaserApp, TaserMountedApp, TaserNativeBound } from "./taser-app.js";
|
|
5
5
|
import { TaserRouter, createTaserApp } from "./taser-router.js";
|
|
6
6
|
import { createContext } from "./create-context.js";
|
|
7
|
-
import { ValidationError, isReplyResult, reply, validationErrorSchema } from "@taserjs/router-utils";
|
|
8
|
-
export { TaserApp, TaserMountedApp, TaserNativeBound, TaserRouter, ValidationError, createAllRoute, createAnyRoute, createContext, createTaserApp, defineHandler, defineMiddleware, isReplyResult, reply, validationErrorSchema };
|
|
7
|
+
import { ValidationError, isReplyResult, reply, stream, validationErrorSchema } from "@taserjs/router-utils";
|
|
8
|
+
export { TaserApp, TaserMountedApp, TaserNativeBound, TaserRouter, ValidationError, createAllRoute, createAnyRoute, createContext, createTaserApp, defineHandler, defineMiddleware, isReplyResult, reply, stream, validationErrorSchema };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineMiddleware } from "../define/middleware.js";
|
|
2
|
-
import { ValidationError, validateSchema } from "@taserjs/router-utils";
|
|
2
|
+
import { ValidationError, reply, validateSchema } from "@taserjs/router-utils";
|
|
3
3
|
import { createTaserCompatHandler } from "@taserjs/router-core";
|
|
4
4
|
//#region src/middleware/auth.ts
|
|
5
5
|
function wrapHonoMiddleware(honoFactory) {
|
|
@@ -17,7 +17,7 @@ function createAuthMiddleware(payloadSchema, honoMw) {
|
|
|
17
17
|
try {
|
|
18
18
|
return next({ state: { jwtPayload: await validateSchema(payloadSchema, payload) } });
|
|
19
19
|
} catch (error) {
|
|
20
|
-
if (error instanceof ValidationError) return
|
|
20
|
+
if (error instanceof ValidationError) return reply.forbidden({
|
|
21
21
|
error: "Forbidden",
|
|
22
22
|
issues: error.issues
|
|
23
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":[],"sources":["../../../src/middleware/auth.ts"],"sourcesContent":["import { createTaserCompatHandler } from '@taserjs/router-core'\nimport { validateSchema, ValidationError } from '@taserjs/router-utils'\nimport type { MiddlewareHandler } from 'hono'\n\nimport { defineMiddleware } from '../define/middleware.js'\nimport type { InferOutput, Schema } from '../types/schema.js'\nimport type { MiddlewareReturnFromParts, MiddlewareUnit } from '../types/units.js'\n\nexport function wrapHonoMiddleware<F extends (...args: never[]) => MiddlewareHandler>(\n honoFactory: F,\n): (...args: Parameters<F>) => MiddlewareUnit<MiddlewareReturnFromParts<unknown, unknown, unknown, {}>> {\n return (...args) => defineMiddleware(honoFactory(...args))\n}\n\nexport type JwtPayloadState<TPayload> = {\n jwtPayload: TPayload\n}\n\nexport type AuthMiddlewareUnit<TPayload> = MiddlewareUnit<\n MiddlewareReturnFromParts<unknown, unknown, unknown, JwtPayloadState<TPayload>>\n>\n\nfunction asJwtPayloadStateSchema<TPayload>(\n payloadSchema: Schema<TPayload>,\n): Schema<JwtPayloadState<InferOutput<Schema<TPayload>>>> {\n return payloadSchema as unknown as Schema<JwtPayloadState<InferOutput<Schema<TPayload>>>>\n}\n\nexport function createAuthMiddleware<TPayload>(\n payloadSchema: Schema<TPayload>,\n honoMw: MiddlewareHandler,\n): AuthMiddlewareUnit<InferOutput<Schema<TPayload>>> {\n return defineMiddleware({\n state: asJwtPayloadStateSchema(payloadSchema),\n handler: (ctx, next) => {\n return createTaserCompatHandler(honoMw)(ctx, async () => {\n const payload = (ctx as unknown as { var: { jwtPayload?: unknown } }).var.jwtPayload\n try {\n const validated = await validateSchema(payloadSchema, payload)\n return next({ state: { jwtPayload: validated } })\n }\n catch (error) {\n if (error instanceof ValidationError) {\n return
|
|
1
|
+
{"version":3,"file":"auth.js","names":[],"sources":["../../../src/middleware/auth.ts"],"sourcesContent":["import { createTaserCompatHandler } from '@taserjs/router-core'\nimport { reply, validateSchema, ValidationError } from '@taserjs/router-utils'\nimport type { MiddlewareHandler } from 'hono'\n\nimport { defineMiddleware } from '../define/middleware.js'\nimport type { InferOutput, Schema } from '../types/schema.js'\nimport type { MiddlewareReturnFromParts, MiddlewareUnit } from '../types/units.js'\n\nexport function wrapHonoMiddleware<F extends (...args: never[]) => MiddlewareHandler>(\n honoFactory: F,\n): (...args: Parameters<F>) => MiddlewareUnit<MiddlewareReturnFromParts<unknown, unknown, unknown, {}>> {\n return (...args) => defineMiddleware(honoFactory(...args))\n}\n\nexport type JwtPayloadState<TPayload> = {\n jwtPayload: TPayload\n}\n\nexport type AuthMiddlewareUnit<TPayload> = MiddlewareUnit<\n MiddlewareReturnFromParts<unknown, unknown, unknown, JwtPayloadState<TPayload>>\n>\n\nfunction asJwtPayloadStateSchema<TPayload>(\n payloadSchema: Schema<TPayload>,\n): Schema<JwtPayloadState<InferOutput<Schema<TPayload>>>> {\n return payloadSchema as unknown as Schema<JwtPayloadState<InferOutput<Schema<TPayload>>>>\n}\n\nexport function createAuthMiddleware<TPayload>(\n payloadSchema: Schema<TPayload>,\n honoMw: MiddlewareHandler,\n): AuthMiddlewareUnit<InferOutput<Schema<TPayload>>> {\n return defineMiddleware({\n state: asJwtPayloadStateSchema(payloadSchema),\n handler: (ctx, next) => {\n return createTaserCompatHandler(honoMw)(ctx, async () => {\n const payload = (ctx as unknown as { var: { jwtPayload?: unknown } }).var.jwtPayload\n try {\n const validated = await validateSchema(payloadSchema, payload)\n return next({ state: { jwtPayload: validated } })\n }\n catch (error) {\n if (error instanceof ValidationError) {\n return reply.forbidden({ error: 'Forbidden', issues: error.issues })\n }\n throw error\n }\n })\n },\n })\n}\n"],"mappings":";;;;AAQA,SAAgB,mBACd,aACsG;CACtG,QAAQ,GAAG,SAAS,iBAAiB,YAAY,GAAG,IAAI,CAAC;AAC3D;AAUA,SAAS,wBACP,eACwD;CACxD,OAAO;AACT;AAEA,SAAgB,qBACd,eACA,QACmD;CACnD,OAAO,iBAAiB;EACtB,OAAO,wBAAwB,aAAa;EAC5C,UAAU,KAAK,SAAS;GACtB,OAAO,yBAAyB,MAAM,CAAC,CAAC,KAAK,YAAY;IACvD,MAAM,UAAW,IAAqD,IAAI;IAC1E,IAAI;KAEF,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,MADX,eAAe,eAAe,OAAO,EAChB,EAAE,CAAC;IAClD,SACO,OAAO;KACZ,IAAI,iBAAiB,iBACnB,OAAO,MAAM,UAAU;MAAE,OAAO;MAAa,QAAQ,MAAM;KAAO,CAAC;KAErE,MAAM;IACR;GACF,CAAC;EACH;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { blob, buffer, file, pipe, stream, } from '@taserjs/router-utils';
|
|
@@ -45,7 +45,6 @@ export type RuntimeContextFields<TNative = unknown> = {
|
|
|
45
45
|
url: URL;
|
|
46
46
|
headers: import('@taserjs/router-core').TaserHeaders;
|
|
47
47
|
cookies: import('@taserjs/router-core').TaserCookieJar;
|
|
48
|
-
reply: typeof import('@taserjs/router-utils').reply;
|
|
49
48
|
var: Record<string, unknown>;
|
|
50
49
|
native?: TNative;
|
|
51
50
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taserjs/router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Type-safe Node.js router with runtime validation and middleware",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,6 +18,26 @@
|
|
|
18
18
|
"default": "./dist/cjs/index.cjs"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
+
"./reply": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/esm/reply.d.ts",
|
|
24
|
+
"default": "./dist/esm/reply.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/cjs/reply.d.cts",
|
|
28
|
+
"default": "./dist/cjs/reply.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./stream": {
|
|
32
|
+
"import": {
|
|
33
|
+
"types": "./dist/esm/stream.d.ts",
|
|
34
|
+
"default": "./dist/esm/stream.js"
|
|
35
|
+
},
|
|
36
|
+
"require": {
|
|
37
|
+
"types": "./dist/cjs/stream.d.cts",
|
|
38
|
+
"default": "./dist/cjs/stream.cjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
21
41
|
"./body-limit": {
|
|
22
42
|
"import": {
|
|
23
43
|
"types": "./dist/esm/middleware/body-limit.d.ts",
|
|
@@ -117,8 +137,8 @@
|
|
|
117
137
|
"dependencies": {
|
|
118
138
|
"@standard-schema/spec": "^1.1.0",
|
|
119
139
|
"hono": "^4.10.3",
|
|
120
|
-
"@taserjs/router-core": "0.0.
|
|
121
|
-
"@taserjs/router-utils": "0.0.
|
|
140
|
+
"@taserjs/router-core": "0.0.2",
|
|
141
|
+
"@taserjs/router-utils": "0.0.2"
|
|
122
142
|
},
|
|
123
143
|
"devDependencies": {
|
|
124
144
|
"@tanstack/vite-config": "^0.6.0",
|
package/src/index.ts
CHANGED
package/src/middleware/auth.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createTaserCompatHandler } from '@taserjs/router-core'
|
|
2
|
-
import { validateSchema, ValidationError } from '@taserjs/router-utils'
|
|
2
|
+
import { reply, validateSchema, ValidationError } from '@taserjs/router-utils'
|
|
3
3
|
import type { MiddlewareHandler } from 'hono'
|
|
4
4
|
|
|
5
5
|
import { defineMiddleware } from '../define/middleware.js'
|
|
@@ -41,7 +41,7 @@ export function createAuthMiddleware<TPayload>(
|
|
|
41
41
|
}
|
|
42
42
|
catch (error) {
|
|
43
43
|
if (error instanceof ValidationError) {
|
|
44
|
-
return
|
|
44
|
+
return reply.forbidden({ error: 'Forbidden', issues: error.issues })
|
|
45
45
|
}
|
|
46
46
|
throw error
|
|
47
47
|
}
|
package/src/reply.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export {
|
|
2
|
+
errorReply,
|
|
3
|
+
reply,
|
|
4
|
+
successReply,
|
|
5
|
+
} from '@taserjs/router-utils/reply'
|
|
6
|
+
export type {
|
|
7
|
+
BinaryBody,
|
|
8
|
+
BodyKind,
|
|
9
|
+
FileReplyInit,
|
|
10
|
+
RedirectInit,
|
|
11
|
+
ReplyBodyKind,
|
|
12
|
+
ReplyInit,
|
|
13
|
+
ReplyOf,
|
|
14
|
+
SuccessReplyData,
|
|
15
|
+
} from '@taserjs/router-utils/reply'
|
package/src/stream.ts
ADDED
package/src/types/type-utils.ts
CHANGED
|
@@ -80,7 +80,6 @@ export type RuntimeContextFields<TNative = unknown> = {
|
|
|
80
80
|
url: URL
|
|
81
81
|
headers: import('@taserjs/router-core').TaserHeaders
|
|
82
82
|
cookies: import('@taserjs/router-core').TaserCookieJar
|
|
83
|
-
reply: typeof import('@taserjs/router-utils').reply
|
|
84
83
|
var: Record<string, unknown>
|
|
85
84
|
native?: TNative
|
|
86
85
|
}
|