@bgord/bun 1.6.0 → 1.6.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/client.vo.d.ts +3 -1
- package/dist/client.vo.d.ts.map +1 -1
- package/dist/client.vo.js +8 -1
- package/dist/client.vo.js.map +1 -1
- package/dist/http-logger.middleware.js +2 -2
- package/dist/http-logger.middleware.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/{job-handler.service.d.ts → job-handler-with-logger.adapter.d.ts} +3 -9
- package/dist/job-handler-with-logger.adapter.d.ts.map +1 -0
- package/dist/{job-handler.service.js → job-handler-with-logger.adapter.js} +2 -5
- package/dist/job-handler-with-logger.adapter.js.map +1 -0
- package/dist/job-handler.port.d.ts +9 -0
- package/dist/job-handler.port.d.ts.map +1 -0
- package/dist/job-handler.port.js +2 -0
- package/dist/job-handler.port.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{visitor-id-hash.adapter.d.ts → visitor-id-client.adapter.d.ts} +2 -2
- package/dist/visitor-id-client.adapter.d.ts.map +1 -0
- package/dist/{visitor-id-hash.adapter.js → visitor-id-client.adapter.js} +2 -2
- package/dist/visitor-id-client.adapter.js.map +1 -0
- package/package.json +1 -1
- package/readme.md +3 -4
- package/src/client.vo.ts +15 -1
- package/src/http-logger.middleware.ts +2 -2
- package/src/index.ts +3 -4
- package/src/{job-handler.service.ts → job-handler-with-logger.adapter.ts} +2 -12
- package/src/job-handler.port.ts +10 -0
- package/src/{visitor-id-hash.adapter.ts → visitor-id-client.adapter.ts} +1 -1
- package/dist/client-from-hono.adapter.d.ts +0 -6
- package/dist/client-from-hono.adapter.d.ts.map +0 -1
- package/dist/client-from-hono.adapter.js +0 -11
- package/dist/client-from-hono.adapter.js.map +0 -1
- package/dist/job-handler.service.d.ts.map +0 -1
- package/dist/job-handler.service.js.map +0 -1
- package/dist/visitor-id-hash-hono.adapter.d.ts +0 -13
- package/dist/visitor-id-hash-hono.adapter.d.ts.map +0 -1
- package/dist/visitor-id-hash-hono.adapter.js +0 -12
- package/dist/visitor-id-hash-hono.adapter.js.map +0 -1
- package/dist/visitor-id-hash.adapter.d.ts.map +0 -1
- package/dist/visitor-id-hash.adapter.js.map +0 -1
- package/src/client-from-hono.adapter.ts +0 -16
- package/src/visitor-id-hash-hono.adapter.ts +0 -19
|
@@ -4,11 +4,11 @@ import type { VisitorIdPort } from "./visitor-id.port";
|
|
|
4
4
|
type Dependencies = {
|
|
5
5
|
HashContent: HashContentPort;
|
|
6
6
|
};
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class VisitorIdClientAdapter implements VisitorIdPort {
|
|
8
8
|
private readonly client;
|
|
9
9
|
private readonly deps;
|
|
10
10
|
constructor(client: Client, deps: Dependencies);
|
|
11
11
|
get(): Promise<import("./hash.vo").Hash>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
14
|
-
//# sourceMappingURL=visitor-id-
|
|
14
|
+
//# sourceMappingURL=visitor-id-client.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-id-client.adapter.d.ts","sourceRoot":"","sources":["../src/visitor-id-client.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,sBAAuB,YAAW,aAAa;IAExD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADJ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY;IAG/B,GAAG;CAOV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class VisitorIdClientAdapter {
|
|
2
2
|
client;
|
|
3
3
|
deps;
|
|
4
4
|
constructor(client, deps) {
|
|
@@ -11,4 +11,4 @@ export class VisitorIdHashAdapter {
|
|
|
11
11
|
return this.deps.HashContent.hash(value);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=visitor-id-
|
|
14
|
+
//# sourceMappingURL=visitor-id-client.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-id-client.adapter.js","sourceRoot":"","sources":["../src/visitor-id-client.adapter.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,sBAAsB;IAEd;IACA;IAFnB,YACmB,MAAc,EACd,IAAkB;QADlB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAc;IAClC,CAAC;IAEJ,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAExC,MAAM,KAAK,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -54,7 +54,6 @@ src/
|
|
|
54
54
|
├── certificate-inspector-tls.adapter.ts
|
|
55
55
|
├── certificate-inspector.port.ts
|
|
56
56
|
├── checksum.service.ts
|
|
57
|
-
├── client-from-hono.adapter.ts
|
|
58
57
|
├── client.vo.ts
|
|
59
58
|
├── clock-fixed.adapter.ts
|
|
60
59
|
├── clock-system.adapter.ts
|
|
@@ -154,7 +153,8 @@ src/
|
|
|
154
153
|
├── image-resizer.port.ts
|
|
155
154
|
├── invariant-error-handler.service.ts
|
|
156
155
|
├── invariant.service.ts
|
|
157
|
-
├── job-handler.
|
|
156
|
+
├── job-handler-with-logger.adapter.ts
|
|
157
|
+
├── job-handler.port.ts
|
|
158
158
|
├── jobs.service.ts
|
|
159
159
|
├── json-file-reader-bun-forgiving.adapter.ts
|
|
160
160
|
├── json-file-reader-bun.adapter.ts
|
|
@@ -277,8 +277,7 @@ src/
|
|
|
277
277
|
├── translations.service.ts
|
|
278
278
|
├── uptime.service.ts
|
|
279
279
|
├── uuid.vo.ts
|
|
280
|
-
├── visitor-id-
|
|
281
|
-
├── visitor-id-hash.adapter.ts
|
|
280
|
+
├── visitor-id-client.adapter.ts
|
|
282
281
|
├── visitor-id.port.ts
|
|
283
282
|
└── weak-etag-extractor.middleware.ts
|
|
284
283
|
```
|
package/src/client.vo.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import { getConnInfo } from "hono/bun";
|
|
3
|
+
|
|
1
4
|
export type ClientIpType = string;
|
|
2
5
|
export type ClientUaType = string;
|
|
3
6
|
export type ClientType = { ip: ClientIpType; ua: ClientUaType };
|
|
@@ -5,10 +8,21 @@ export type ClientType = { ip: ClientIpType; ua: ClientUaType };
|
|
|
5
8
|
export class Client {
|
|
6
9
|
private constructor(private readonly value: ClientType) {}
|
|
7
10
|
|
|
8
|
-
static
|
|
11
|
+
static fromParts(ip: ClientIpType | null | undefined, ua: ClientUaType | null | undefined): Client {
|
|
9
12
|
return new Client({ ip: ip ?? "anon", ua: ua ?? "anon" });
|
|
10
13
|
}
|
|
11
14
|
|
|
15
|
+
static fromHonoContext(context: Context): Client {
|
|
16
|
+
const info = getConnInfo(context);
|
|
17
|
+
|
|
18
|
+
const ip =
|
|
19
|
+
context.req.header("x-real-ip") || context.req.header("x-forwarded-for") || info?.remote?.address;
|
|
20
|
+
|
|
21
|
+
const ua = context.req.header("user-agent");
|
|
22
|
+
|
|
23
|
+
return Client.fromParts(ip, ua);
|
|
24
|
+
}
|
|
25
|
+
|
|
12
26
|
toJSON(): ClientType {
|
|
13
27
|
return this.value;
|
|
14
28
|
}
|
|
@@ -2,7 +2,7 @@ import * as tools from "@bgord/tools";
|
|
|
2
2
|
import { createMiddleware } from "hono/factory";
|
|
3
3
|
import { CacheSourceEnum } from "./cache-resolver.port";
|
|
4
4
|
import { CacheResponse } from "./cache-response.middleware";
|
|
5
|
-
import {
|
|
5
|
+
import { Client } from "./client.vo";
|
|
6
6
|
import type { ClockPort } from "./clock.port";
|
|
7
7
|
import type { LoggerPort } from "./logger.port";
|
|
8
8
|
|
|
@@ -45,7 +45,7 @@ export class HttpLogger {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const correlationId = context.get("requestId");
|
|
48
|
-
const client =
|
|
48
|
+
const client = Client.fromHonoContext(context).toJSON();
|
|
49
49
|
|
|
50
50
|
const httpRequestBeforeMetadata = {
|
|
51
51
|
params: context.req.param(),
|
package/src/index.ts
CHANGED
|
@@ -28,7 +28,6 @@ export * from "./certificate-inspector-noop.adapter";
|
|
|
28
28
|
export * from "./certificate-inspector-tls.adapter";
|
|
29
29
|
export * from "./checksum.service";
|
|
30
30
|
export * from "./client.vo";
|
|
31
|
-
export * from "./client-from-hono.adapter";
|
|
32
31
|
export * from "./clock.port";
|
|
33
32
|
export * from "./clock-fixed.adapter";
|
|
34
33
|
export * from "./clock-system.adapter";
|
|
@@ -129,7 +128,8 @@ export * from "./image-resizer-noop.adapter";
|
|
|
129
128
|
export * from "./image-resizer-sharp.adapter";
|
|
130
129
|
export * from "./invariant.service";
|
|
131
130
|
export * from "./invariant-error-handler.service";
|
|
132
|
-
export * from "./job-handler.
|
|
131
|
+
export * from "./job-handler.port";
|
|
132
|
+
export * from "./job-handler-with-logger.adapter";
|
|
133
133
|
export * from "./jobs.service";
|
|
134
134
|
export * from "./json-file-reader.port";
|
|
135
135
|
export * from "./json-file-reader-bun.adapter";
|
|
@@ -197,6 +197,5 @@ export * from "./translations.service";
|
|
|
197
197
|
export * from "./uptime.service";
|
|
198
198
|
export * from "./uuid.vo";
|
|
199
199
|
export * from "./visitor-id.port";
|
|
200
|
-
export * from "./visitor-id-
|
|
201
|
-
export * from "./visitor-id-hash-hono.adapter";
|
|
200
|
+
export * from "./visitor-id-client.adapter";
|
|
202
201
|
export * from "./weak-etag-extractor.middleware";
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import * as tools from "@bgord/tools";
|
|
2
|
-
import type { Cron } from "croner";
|
|
3
2
|
import type { ClockPort } from "./clock.port";
|
|
4
3
|
import { CorrelationStorage } from "./correlation-storage.service";
|
|
5
4
|
import type { IdProviderPort } from "./id-provider.port";
|
|
6
|
-
import type {
|
|
5
|
+
import type { JobHandlerPort, UnitOfWork } from "./job-handler.port";
|
|
7
6
|
import type { LoggerPort } from "./logger.port";
|
|
8
7
|
import { formatError } from "./logger-format-error.service";
|
|
9
8
|
|
|
10
9
|
type Dependencies = { Logger: LoggerPort; IdProvider: IdProviderPort; Clock: ClockPort };
|
|
11
10
|
|
|
12
|
-
export
|
|
13
|
-
label: JobNameType;
|
|
14
|
-
process: () => Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class JobHandler {
|
|
11
|
+
export class JobHandlerWithLogger implements JobHandlerPort {
|
|
18
12
|
private readonly base = { component: "infra", operation: "job_handler" };
|
|
19
13
|
|
|
20
14
|
constructor(private readonly deps: Dependencies) {}
|
|
@@ -47,8 +41,4 @@ export class JobHandler {
|
|
|
47
41
|
}
|
|
48
42
|
};
|
|
49
43
|
}
|
|
50
|
-
|
|
51
|
-
protect(cron: Cron) {
|
|
52
|
-
return async () => this.deps.Logger.info({ message: `${cron.name} overrun`, ...this.base });
|
|
53
|
-
}
|
|
54
44
|
}
|
|
@@ -4,7 +4,7 @@ import type { VisitorIdPort } from "./visitor-id.port";
|
|
|
4
4
|
|
|
5
5
|
type Dependencies = { HashContent: HashContentPort };
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class VisitorIdClientAdapter implements VisitorIdPort {
|
|
8
8
|
constructor(
|
|
9
9
|
private readonly client: Client,
|
|
10
10
|
private readonly deps: Dependencies,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-from-hono.adapter.d.ts","sourceRoot":"","sources":["../src/client-from-hono.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,qBAAa,qBAAqB;IAChC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;CAUzC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getConnInfo } from "hono/bun";
|
|
2
|
-
import { Client } from "./client.vo";
|
|
3
|
-
export class ClientFromHonoAdapter {
|
|
4
|
-
static extract(context) {
|
|
5
|
-
const info = getConnInfo(context);
|
|
6
|
-
const ip = context.req.header("x-real-ip") || context.req.header("x-forwarded-for") || info?.remote?.address;
|
|
7
|
-
const ua = context.req.header("user-agent");
|
|
8
|
-
return Client.from(ip, ua);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=client-from-hono.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-from-hono.adapter.js","sourceRoot":"","sources":["../src/client-from-hono.adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,qBAAqB;IAChC,MAAM,CAAC,OAAO,CAAC,OAAgB;QAC7B,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAElC,MAAM,EAAE,GACN,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;QAEpG,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAE5C,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"job-handler.service.d.ts","sourceRoot":"","sources":["../src/job-handler.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,KAAK,YAAY,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEzF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,qBAAa,UAAU;IAGT,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoD;gBAE5C,IAAI,EAAE,YAAY;IAE/C,MAAM,CAAC,GAAG,EAAE,UAAU;IA6BtB,OAAO,CAAC,IAAI,EAAE,IAAI;CAGnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"job-handler.service.js","sourceRoot":"","sources":["../src/job-handler.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAS5D,MAAM,OAAO,UAAU;IAGQ;IAFZ,IAAI,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;IAEzE,YAA6B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAEnD,MAAM,CAAC,GAAe;QACpB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QAEtD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAE7D,IAAI,CAAC;gBACH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,KAAK,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBAEtF,MAAM,kBAAkB,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBAEvE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;oBACpB,OAAO,EAAE,GAAG,GAAG,CAAC,KAAK,UAAU;oBAC/B,aAAa;oBACb,QAAQ,EAAE,SAAS,CAAC,IAAI,EAAE;oBAC1B,GAAG,IAAI,CAAC,IAAI;iBACb,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;oBACrB,OAAO,EAAE,GAAG,GAAG,CAAC,KAAK,QAAQ;oBAC7B,aAAa;oBACb,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC;oBACzB,QAAQ,EAAE,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE;oBACjC,GAAG,IAAI,CAAC,IAAI;iBACb,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAU;QAChB,OAAO,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,UAAU,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9F,CAAC;CACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Context } from "hono";
|
|
2
|
-
import type { HashContentPort } from "./hash-content.port";
|
|
3
|
-
import type { VisitorIdPort } from "./visitor-id.port";
|
|
4
|
-
type Dependencies = {
|
|
5
|
-
HashContent: HashContentPort;
|
|
6
|
-
};
|
|
7
|
-
export declare class VisitorIdHashHonoAdapter implements VisitorIdPort {
|
|
8
|
-
private readonly delegate;
|
|
9
|
-
constructor(context: Context, deps: Dependencies);
|
|
10
|
-
get(): Promise<import("./hash.vo").Hash>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=visitor-id-hash-hono.adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-id-hash-hono.adapter.d.ts","sourceRoot":"","sources":["../src/visitor-id-hash-hono.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,wBAAyB,YAAW,aAAa;IAC5D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;gBAEpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;IAI1C,GAAG;CAGV"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ClientFromHonoAdapter } from "./client-from-hono.adapter";
|
|
2
|
-
import { VisitorIdHashAdapter } from "./visitor-id-hash.adapter";
|
|
3
|
-
export class VisitorIdHashHonoAdapter {
|
|
4
|
-
delegate;
|
|
5
|
-
constructor(context, deps) {
|
|
6
|
-
this.delegate = new VisitorIdHashAdapter(ClientFromHonoAdapter.extract(context), deps);
|
|
7
|
-
}
|
|
8
|
-
async get() {
|
|
9
|
-
return this.delegate.get();
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=visitor-id-hash-hono.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-id-hash-hono.adapter.js","sourceRoot":"","sources":["../src/visitor-id-hash-hono.adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAIjE,MAAM,OAAO,wBAAwB;IAClB,QAAQ,CAAuB;IAEhD,YAAY,OAAgB,EAAE,IAAkB;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAoB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-id-hash.adapter.d.ts","sourceRoot":"","sources":["../src/visitor-id-hash.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,oBAAqB,YAAW,aAAa;IAEtD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADJ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY;IAG/B,GAAG;CAOV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-id-hash.adapter.js","sourceRoot":"","sources":["../src/visitor-id-hash.adapter.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,oBAAoB;IAEZ;IACA;IAFnB,YACmB,MAAc,EACd,IAAkB;QADlB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAc;IAClC,CAAC;IAEJ,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAExC,MAAM,KAAK,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Context } from "hono";
|
|
2
|
-
import { getConnInfo } from "hono/bun";
|
|
3
|
-
import { Client } from "./client.vo";
|
|
4
|
-
|
|
5
|
-
export class ClientFromHonoAdapter {
|
|
6
|
-
static extract(context: Context): Client {
|
|
7
|
-
const info = getConnInfo(context);
|
|
8
|
-
|
|
9
|
-
const ip =
|
|
10
|
-
context.req.header("x-real-ip") || context.req.header("x-forwarded-for") || info?.remote?.address;
|
|
11
|
-
|
|
12
|
-
const ua = context.req.header("user-agent");
|
|
13
|
-
|
|
14
|
-
return Client.from(ip, ua);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Context } from "hono";
|
|
2
|
-
import { ClientFromHonoAdapter } from "./client-from-hono.adapter";
|
|
3
|
-
import type { HashContentPort } from "./hash-content.port";
|
|
4
|
-
import type { VisitorIdPort } from "./visitor-id.port";
|
|
5
|
-
import { VisitorIdHashAdapter } from "./visitor-id-hash.adapter";
|
|
6
|
-
|
|
7
|
-
type Dependencies = { HashContent: HashContentPort };
|
|
8
|
-
|
|
9
|
-
export class VisitorIdHashHonoAdapter implements VisitorIdPort {
|
|
10
|
-
private readonly delegate: VisitorIdHashAdapter;
|
|
11
|
-
|
|
12
|
-
constructor(context: Context, deps: Dependencies) {
|
|
13
|
-
this.delegate = new VisitorIdHashAdapter(ClientFromHonoAdapter.extract(context), deps);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async get() {
|
|
17
|
-
return this.delegate.get();
|
|
18
|
-
}
|
|
19
|
-
}
|