@kanjijs/platform-hono 0.2.0-beta.12 → 0.2.0-beta.14
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/adapter.d.ts +20 -0
- package/dist/filter.d.ts +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/dist/middleware.d.ts +7 -0
- package/package.json +5 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { cors } from "hono/cors";
|
|
3
|
+
import { secureHeaders } from "hono/secure-headers";
|
|
4
|
+
import { logger } from "hono/logger";
|
|
5
|
+
import { type Constructor, type ValidatorAdapter, Container } from "@kanjijs/core";
|
|
6
|
+
export interface KanjijsAdapterOptions {
|
|
7
|
+
validator?: ValidatorAdapter;
|
|
8
|
+
globalPrefix?: string;
|
|
9
|
+
cors?: boolean | Parameters<typeof cors>[0];
|
|
10
|
+
helmet?: boolean | Parameters<typeof secureHeaders>[0];
|
|
11
|
+
logger?: boolean | Parameters<typeof logger>[0];
|
|
12
|
+
}
|
|
13
|
+
export declare class KanjijsAdapter {
|
|
14
|
+
static create(rootModule: Constructor, optionsOrValidator?: ValidatorAdapter | KanjijsAdapterOptions): {
|
|
15
|
+
app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
16
|
+
container: Container;
|
|
17
|
+
};
|
|
18
|
+
private static findControllers;
|
|
19
|
+
private static registerController;
|
|
20
|
+
}
|
package/dist/filter.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import { type ExceptionFilter } from "@kanjijs/core";
|
|
3
|
+
export declare class KanjijsExceptionFilter implements ExceptionFilter {
|
|
4
|
+
catch(exception: unknown, c: Context): Response & import("hono").TypedResponse<{
|
|
5
|
+
statusCode: number;
|
|
6
|
+
message: string;
|
|
7
|
+
error: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
requestId: import("hono/utils/types").JSONValue;
|
|
10
|
+
}, any, "json">;
|
|
11
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./adapter";
|
package/dist/index.js
CHANGED
|
@@ -3115,7 +3115,7 @@ class ModuleCompiler {
|
|
|
3115
3115
|
const paramTypes = Reflect.getMetadata("design:paramtypes", clazz) || [];
|
|
3116
3116
|
const injectionTokens = MetadataStorage.getInjections(clazz) || new Map;
|
|
3117
3117
|
dependencies = paramTypes.map((t, i) => injectionTokens.get(i) || t);
|
|
3118
|
-
} else if ("useFactory" in provider
|
|
3118
|
+
} else if ("useFactory" in provider) {
|
|
3119
3119
|
targetName = provider.provide?.name || String(provider.provide);
|
|
3120
3120
|
dependencies = provider.inject || [];
|
|
3121
3121
|
}
|
|
@@ -3241,11 +3241,11 @@ class KanjijsAdapter {
|
|
|
3241
3241
|
globalPrefix = opts.globalPrefix || "";
|
|
3242
3242
|
options.cors = opts.cors;
|
|
3243
3243
|
options.helmet = opts.helmet;
|
|
3244
|
-
options.
|
|
3244
|
+
options.logger = opts.logger;
|
|
3245
3245
|
}
|
|
3246
3246
|
}
|
|
3247
|
-
if (options.
|
|
3248
|
-
const loggerOpts = typeof options.
|
|
3247
|
+
if (options.logger) {
|
|
3248
|
+
const loggerOpts = typeof options.logger === "boolean" ? undefined : options.logger;
|
|
3249
3249
|
app.use("*", logger(loggerOpts));
|
|
3250
3250
|
}
|
|
3251
3251
|
if (options.helmet) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContractSpec, ValidatorAdapter } from "@kanjijs/contracts";
|
|
2
|
+
import type { Context, Next } from "hono";
|
|
3
|
+
export declare function createValidationMiddleware(spec: ContractSpec, validator: ValidatorAdapter): (c: Context, next: Next) => Promise<(Response & import("hono").TypedResponse<{
|
|
4
|
+
error: string;
|
|
5
|
+
message: string;
|
|
6
|
+
issues: import("hono/utils/types").JSONValue[];
|
|
7
|
+
}, 400, "json">) | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanjijs/platform-hono",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
"LICENSE"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "bun build src/index.ts --outdir dist --target bun"
|
|
13
|
+
"build": "bun build src/index.ts --outdir dist --target bun && tsc --emitDeclarationOnly --declaration --outDir dist"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@kanjijs/common": "^0.2.0-beta.
|
|
17
|
-
"@kanjijs/contracts": "^0.2.0-beta.
|
|
16
|
+
"@kanjijs/common": "^0.2.0-beta.14",
|
|
17
|
+
"@kanjijs/contracts": "^0.2.0-beta.14",
|
|
18
18
|
"hono": "^4.0.0",
|
|
19
19
|
"reflect-metadata": "^0.2.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@kanjijs/core": "^0.2.0-beta.
|
|
22
|
+
"@kanjijs/core": "^0.2.0-beta.14"
|
|
23
23
|
}
|
|
24
24
|
}
|