@shware/http 0.2.12 → 0.2.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/hono/geolocation.cjs +26 -14
- package/dist/hono/geolocation.cjs.map +1 -1
- package/dist/hono/geolocation.d.cts +1 -2
- package/dist/hono/geolocation.d.ts +1 -2
- package/dist/hono/geolocation.mjs +26 -14
- package/dist/hono/geolocation.mjs.map +1 -1
- package/dist/hono/handler.cjs +1 -1
- package/dist/hono/handler.cjs.map +1 -1
- package/dist/hono/handler.mjs +1 -1
- package/dist/hono/handler.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -24,8 +24,8 @@ __export(geolocation_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(geolocation_exports);
|
|
26
26
|
var import_adapter = require("hono/adapter");
|
|
27
|
+
var runtime = (0, import_adapter.getRuntimeKey)();
|
|
27
28
|
function geolocation(c) {
|
|
28
|
-
const runtime = (0, import_adapter.getRuntimeKey)();
|
|
29
29
|
if (runtime === "workerd") {
|
|
30
30
|
return {
|
|
31
31
|
ip: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip") ?? null,
|
|
@@ -34,25 +34,37 @@ function geolocation(c) {
|
|
|
34
34
|
continent: c.req.header("cf-ipcontinent") ?? null,
|
|
35
35
|
longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : null,
|
|
36
36
|
latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) : null,
|
|
37
|
-
region: c.req.header("cf-region") ?? null,
|
|
38
|
-
region_code: c.req.header("cf-region-code") ?? null,
|
|
37
|
+
region: c.req.header("cf-region-code") ?? null,
|
|
39
38
|
metro_code: c.req.header("cf-metro-code") ?? null,
|
|
40
39
|
postal_code: c.req.header("cf-postal-code") ?? null,
|
|
41
40
|
timezone: c.req.header("cf-timezone") ?? null
|
|
42
41
|
};
|
|
43
42
|
}
|
|
43
|
+
if (c.req.header("x-vercel-id")) {
|
|
44
|
+
return {
|
|
45
|
+
ip: c.req.header("x-real-ip") ?? null,
|
|
46
|
+
city: c.req.header("x-vercel-ip-city") ?? null,
|
|
47
|
+
country: c.req.header("x-vercel-ip-country") ?? null,
|
|
48
|
+
continent: c.req.header("x-vercel-ip-continent") ?? null,
|
|
49
|
+
longitude: c.req.header("x-vercel-ip-longitude") ? Number(c.req.header("x-vercel-ip-longitude")) : null,
|
|
50
|
+
latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) : null,
|
|
51
|
+
region: c.req.header("x-vercel-ip-country-region") ?? null,
|
|
52
|
+
metro_code: null,
|
|
53
|
+
postal_code: c.req.header("x-vercel-ip-postal-code") ?? null,
|
|
54
|
+
timezone: null
|
|
55
|
+
};
|
|
56
|
+
}
|
|
44
57
|
return {
|
|
45
|
-
ip: c.req.header("
|
|
46
|
-
city: c.req.header("
|
|
47
|
-
country: c.req.header("
|
|
48
|
-
continent:
|
|
49
|
-
longitude: c.req.header("
|
|
50
|
-
latitude: c.req.header("
|
|
51
|
-
region: null,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
timezone: null
|
|
58
|
+
ip: c.req.header("CloudFront-Viewer-Address") ?? null,
|
|
59
|
+
city: c.req.header("CloudFront-Viewer-City") ?? null,
|
|
60
|
+
country: c.req.header("CloudFront-Viewer-Country") ?? null,
|
|
61
|
+
continent: null,
|
|
62
|
+
longitude: c.req.header("CloudFront-Viewer-Longitude") ? Number(c.req.header("CloudFront-Viewer-Longitude")) : null,
|
|
63
|
+
latitude: c.req.header("CloudFront-Viewer-Latitude") ? Number(c.req.header("CloudFront-Viewer-Latitude")) : null,
|
|
64
|
+
region: c.req.header("CloudFront-Viewer-Country-Region") ?? null,
|
|
65
|
+
metro_code: c.req.header("CloudFront-Viewer-Metro-Code") ?? null,
|
|
66
|
+
postal_code: c.req.header("CloudFront-Viewer-Postal-Code") ?? null,
|
|
67
|
+
timezone: c.req.header("CloudFront-Viewer-Time-Zone") ?? null
|
|
56
68
|
};
|
|
57
69
|
}
|
|
58
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import { getRuntimeKey } from 'hono/adapter';\nimport type { Context } from 'hono';\n\nexport type Geolocation = {\n ip: string | null;\n city: string | null;\n country: string | null
|
|
1
|
+
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import { getRuntimeKey } from 'hono/adapter';\nimport type { Context } from 'hono';\n\nexport type Geolocation = {\n ip: string | null;\n city: string | null;\n country: string | null; // ISO 3166-1 alpha-2\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null; // ISO 3166-2\n metro_code: string | null;\n postal_code: string | null;\n timezone: string | null;\n};\n\nconst runtime = getRuntimeKey();\nexport function geolocation(c: Context): Geolocation | null {\n /** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */\n if (runtime === 'workerd') {\n return {\n ip: c.req.header('true-client-ip') ?? c.req.header('cf-connecting-ip') ?? null,\n city: c.req.header('cf-ipcity') ?? null,\n country: c.req.header('cf-ipcountry') ?? null,\n continent: c.req.header('cf-ipcontinent') ?? null,\n longitude: c.req.header('cf-iplongitude') ? Number(c.req.header('cf-iplongitude')) : null,\n latitude: c.req.header('cf-iplatitude') ? Number(c.req.header('cf-iplatitude')) : null,\n region: c.req.header('cf-region-code') ?? null,\n metro_code: c.req.header('cf-metro-code') ?? null,\n postal_code: c.req.header('cf-postal-code') ?? null,\n timezone: c.req.header('cf-timezone') ?? null,\n };\n }\n\n /** https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts */\n if (c.req.header('x-vercel-id')) {\n return {\n ip: c.req.header('x-real-ip') ?? null,\n city: c.req.header('x-vercel-ip-city') ?? null,\n country: c.req.header('x-vercel-ip-country') ?? null,\n continent: c.req.header('x-vercel-ip-continent') ?? null,\n longitude: c.req.header('x-vercel-ip-longitude')\n ? Number(c.req.header('x-vercel-ip-longitude'))\n : null,\n latitude: c.req.header('x-vercel-ip-latitude')\n ? Number(c.req.header('x-vercel-ip-latitude'))\n : null,\n region: c.req.header('x-vercel-ip-country-region') ?? null,\n metro_code: null,\n postal_code: c.req.header('x-vercel-ip-postal-code') ?? null,\n timezone: null,\n };\n }\n\n // cloudfront\n // https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-cloudfront-headers.html#cloudfront-headers-viewer-location\n return {\n ip: c.req.header('CloudFront-Viewer-Address') ?? null,\n city: c.req.header('CloudFront-Viewer-City') ?? null,\n country: c.req.header('CloudFront-Viewer-Country') ?? null,\n continent: null,\n longitude: c.req.header('CloudFront-Viewer-Longitude')\n ? Number(c.req.header('CloudFront-Viewer-Longitude'))\n : null,\n latitude: c.req.header('CloudFront-Viewer-Latitude')\n ? Number(c.req.header('CloudFront-Viewer-Latitude'))\n : null,\n region: c.req.header('CloudFront-Viewer-Country-Region') ?? null,\n metro_code: c.req.header('CloudFront-Viewer-Metro-Code') ?? null,\n postal_code: c.req.header('CloudFront-Viewer-Postal-Code') ?? null,\n timezone: c.req.header('CloudFront-Viewer-Time-Zone') ?? null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAgB9B,IAAM,cAAU,8BAAc;AACvB,SAAS,YAAY,GAAgC;AAE1D,MAAI,YAAY,WAAW;AACzB,WAAO;AAAA,MACL,IAAI,EAAE,IAAI,OAAO,gBAAgB,KAAK,EAAE,IAAI,OAAO,kBAAkB,KAAK;AAAA,MAC1E,MAAM,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,MACnC,SAAS,EAAE,IAAI,OAAO,cAAc,KAAK;AAAA,MACzC,WAAW,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,MAC7C,WAAW,EAAE,IAAI,OAAO,gBAAgB,IAAI,OAAO,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,IAClD;AAAA,IACJ,UAAU,EAAE,IAAI,OAAO,4BAA4B,IAC/C,OAAO,EAAE,IAAI,OAAO,4BAA4B,CAAC,IACjD;AAAA,IACJ,QAAQ,EAAE,IAAI,OAAO,kCAAkC,KAAK;AAAA,IAC5D,YAAY,EAAE,IAAI,OAAO,8BAA8B,KAAK;AAAA,IAC5D,aAAa,EAAE,IAAI,OAAO,+BAA+B,KAAK;AAAA,IAC9D,UAAU,EAAE,IAAI,OAAO,6BAA6B,KAAK;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -8,11 +8,10 @@ type Geolocation = {
|
|
|
8
8
|
longitude: number | null;
|
|
9
9
|
latitude: number | null;
|
|
10
10
|
region: string | null;
|
|
11
|
-
region_code: string | null;
|
|
12
11
|
metro_code: string | null;
|
|
13
12
|
postal_code: string | null;
|
|
14
13
|
timezone: string | null;
|
|
15
14
|
};
|
|
16
|
-
declare function geolocation(c: Context): Geolocation;
|
|
15
|
+
declare function geolocation(c: Context): Geolocation | null;
|
|
17
16
|
|
|
18
17
|
export { type Geolocation, geolocation };
|
|
@@ -8,11 +8,10 @@ type Geolocation = {
|
|
|
8
8
|
longitude: number | null;
|
|
9
9
|
latitude: number | null;
|
|
10
10
|
region: string | null;
|
|
11
|
-
region_code: string | null;
|
|
12
11
|
metro_code: string | null;
|
|
13
12
|
postal_code: string | null;
|
|
14
13
|
timezone: string | null;
|
|
15
14
|
};
|
|
16
|
-
declare function geolocation(c: Context): Geolocation;
|
|
15
|
+
declare function geolocation(c: Context): Geolocation | null;
|
|
17
16
|
|
|
18
17
|
export { type Geolocation, geolocation };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/hono/geolocation.ts
|
|
2
2
|
import { getRuntimeKey } from "hono/adapter";
|
|
3
|
+
var runtime = getRuntimeKey();
|
|
3
4
|
function geolocation(c) {
|
|
4
|
-
const runtime = getRuntimeKey();
|
|
5
5
|
if (runtime === "workerd") {
|
|
6
6
|
return {
|
|
7
7
|
ip: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip") ?? null,
|
|
@@ -10,25 +10,37 @@ function geolocation(c) {
|
|
|
10
10
|
continent: c.req.header("cf-ipcontinent") ?? null,
|
|
11
11
|
longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : null,
|
|
12
12
|
latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) : null,
|
|
13
|
-
region: c.req.header("cf-region") ?? null,
|
|
14
|
-
region_code: c.req.header("cf-region-code") ?? null,
|
|
13
|
+
region: c.req.header("cf-region-code") ?? null,
|
|
15
14
|
metro_code: c.req.header("cf-metro-code") ?? null,
|
|
16
15
|
postal_code: c.req.header("cf-postal-code") ?? null,
|
|
17
16
|
timezone: c.req.header("cf-timezone") ?? null
|
|
18
17
|
};
|
|
19
18
|
}
|
|
19
|
+
if (c.req.header("x-vercel-id")) {
|
|
20
|
+
return {
|
|
21
|
+
ip: c.req.header("x-real-ip") ?? null,
|
|
22
|
+
city: c.req.header("x-vercel-ip-city") ?? null,
|
|
23
|
+
country: c.req.header("x-vercel-ip-country") ?? null,
|
|
24
|
+
continent: c.req.header("x-vercel-ip-continent") ?? null,
|
|
25
|
+
longitude: c.req.header("x-vercel-ip-longitude") ? Number(c.req.header("x-vercel-ip-longitude")) : null,
|
|
26
|
+
latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) : null,
|
|
27
|
+
region: c.req.header("x-vercel-ip-country-region") ?? null,
|
|
28
|
+
metro_code: null,
|
|
29
|
+
postal_code: c.req.header("x-vercel-ip-postal-code") ?? null,
|
|
30
|
+
timezone: null
|
|
31
|
+
};
|
|
32
|
+
}
|
|
20
33
|
return {
|
|
21
|
-
ip: c.req.header("
|
|
22
|
-
city: c.req.header("
|
|
23
|
-
country: c.req.header("
|
|
24
|
-
continent:
|
|
25
|
-
longitude: c.req.header("
|
|
26
|
-
latitude: c.req.header("
|
|
27
|
-
region: null,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
timezone: null
|
|
34
|
+
ip: c.req.header("CloudFront-Viewer-Address") ?? null,
|
|
35
|
+
city: c.req.header("CloudFront-Viewer-City") ?? null,
|
|
36
|
+
country: c.req.header("CloudFront-Viewer-Country") ?? null,
|
|
37
|
+
continent: null,
|
|
38
|
+
longitude: c.req.header("CloudFront-Viewer-Longitude") ? Number(c.req.header("CloudFront-Viewer-Longitude")) : null,
|
|
39
|
+
latitude: c.req.header("CloudFront-Viewer-Latitude") ? Number(c.req.header("CloudFront-Viewer-Latitude")) : null,
|
|
40
|
+
region: c.req.header("CloudFront-Viewer-Country-Region") ?? null,
|
|
41
|
+
metro_code: c.req.header("CloudFront-Viewer-Metro-Code") ?? null,
|
|
42
|
+
postal_code: c.req.header("CloudFront-Viewer-Postal-Code") ?? null,
|
|
43
|
+
timezone: c.req.header("CloudFront-Viewer-Time-Zone") ?? null
|
|
32
44
|
};
|
|
33
45
|
}
|
|
34
46
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import { getRuntimeKey } from 'hono/adapter';\nimport type { Context } from 'hono';\n\nexport type Geolocation = {\n ip: string | null;\n city: string | null;\n country: string | null
|
|
1
|
+
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import { getRuntimeKey } from 'hono/adapter';\nimport type { Context } from 'hono';\n\nexport type Geolocation = {\n ip: string | null;\n city: string | null;\n country: string | null; // ISO 3166-1 alpha-2\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null; // ISO 3166-2\n metro_code: string | null;\n postal_code: string | null;\n timezone: string | null;\n};\n\nconst runtime = getRuntimeKey();\nexport function geolocation(c: Context): Geolocation | null {\n /** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */\n if (runtime === 'workerd') {\n return {\n ip: c.req.header('true-client-ip') ?? c.req.header('cf-connecting-ip') ?? null,\n city: c.req.header('cf-ipcity') ?? null,\n country: c.req.header('cf-ipcountry') ?? null,\n continent: c.req.header('cf-ipcontinent') ?? null,\n longitude: c.req.header('cf-iplongitude') ? Number(c.req.header('cf-iplongitude')) : null,\n latitude: c.req.header('cf-iplatitude') ? Number(c.req.header('cf-iplatitude')) : null,\n region: c.req.header('cf-region-code') ?? null,\n metro_code: c.req.header('cf-metro-code') ?? null,\n postal_code: c.req.header('cf-postal-code') ?? null,\n timezone: c.req.header('cf-timezone') ?? null,\n };\n }\n\n /** https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts */\n if (c.req.header('x-vercel-id')) {\n return {\n ip: c.req.header('x-real-ip') ?? null,\n city: c.req.header('x-vercel-ip-city') ?? null,\n country: c.req.header('x-vercel-ip-country') ?? null,\n continent: c.req.header('x-vercel-ip-continent') ?? null,\n longitude: c.req.header('x-vercel-ip-longitude')\n ? Number(c.req.header('x-vercel-ip-longitude'))\n : null,\n latitude: c.req.header('x-vercel-ip-latitude')\n ? Number(c.req.header('x-vercel-ip-latitude'))\n : null,\n region: c.req.header('x-vercel-ip-country-region') ?? null,\n metro_code: null,\n postal_code: c.req.header('x-vercel-ip-postal-code') ?? null,\n timezone: null,\n };\n }\n\n // cloudfront\n // https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-cloudfront-headers.html#cloudfront-headers-viewer-location\n return {\n ip: c.req.header('CloudFront-Viewer-Address') ?? null,\n city: c.req.header('CloudFront-Viewer-City') ?? null,\n country: c.req.header('CloudFront-Viewer-Country') ?? null,\n continent: null,\n longitude: c.req.header('CloudFront-Viewer-Longitude')\n ? Number(c.req.header('CloudFront-Viewer-Longitude'))\n : null,\n latitude: c.req.header('CloudFront-Viewer-Latitude')\n ? Number(c.req.header('CloudFront-Viewer-Latitude'))\n : null,\n region: c.req.header('CloudFront-Viewer-Country-Region') ?? null,\n metro_code: c.req.header('CloudFront-Viewer-Metro-Code') ?? null,\n postal_code: c.req.header('CloudFront-Viewer-Postal-Code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AE,IAAI,OAAO,sBAAsB,CAAC,IAC3C;AAAA,MACJ,QAAQ,EAAE,IAAI,OAAO,4BAA4B,KAAK;AAAA,MACtD,YAAY;AAAA,MACZ,aAAa,EAAE,IAAI,OAAO,yBAAyB,KAAK;AAAA,MACxD,UAAU;AAAA,IACZ;AAAA,EACF;AAIA,SAAO;AAAA,IACL,IAAI,EAAE,IAAI,OAAO,2BAA2B,KAAK;AAAA,IACjD,MAAM,EAAE,IAAI,OAAO,wBAAwB,KAAK;AAAA,IAChD,SAAS,EAAE,IAAI,OAAO,2BAA2B,KAAK;AAAA,IACtD,WAAW;AAAA,IACX,WAAW,EAAE,IAAI,OAAO,6BAA6B,IACjD,OAAO,EAAE,IAAI,OAAO,6BAA6B,CAAC,IAClD;AAAA,IACJ,UAAU,EAAE,IAAI,OAAO,4BAA4B,IAC/C,OAAO,EAAE,IAAI,OAAO,4BAA4B,CAAC,IACjD;AAAA,IACJ,QAAQ,EAAE,IAAI,OAAO,kCAAkC,KAAK;AAAA,IAC5D,YAAY,EAAE,IAAI,OAAO,8BAA8B,KAAK;AAAA,IAC5D,aAAa,EAAE,IAAI,OAAO,+BAA+B,KAAK;AAAA,IAC9D,UAAU,EAAE,IAAI,OAAO,6BAA6B,KAAK;AAAA,EAC3D;AACF;","names":[]}
|
package/dist/hono/handler.cjs
CHANGED
|
@@ -33,7 +33,7 @@ function errorHandler(error, c) {
|
|
|
33
33
|
error.body?.error?.details?.push(...details.list);
|
|
34
34
|
return c.json(error.body, error.status);
|
|
35
35
|
}
|
|
36
|
-
console.
|
|
36
|
+
console.error(error);
|
|
37
37
|
return import_status.Status.internal("Unknown error").response(details);
|
|
38
38
|
}
|
|
39
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/handler.ts"],"sourcesContent":["import type { Context } from 'hono';\nimport type { HTTPResponseError, Bindings } from 'hono/types';\nimport type { ContentfulStatusCode } from 'hono/utils/http-status';\nimport type { RequestIdVariables } from 'hono/request-id';\nimport { Status, StatusError } from '../status';\nimport { Details } from '../detail';\n\ntype Env = {\n Variables: RequestIdVariables;\n Bindings?: Bindings;\n};\n\nexport function errorHandler<E extends Env = any>(\n error: Error | HTTPResponseError,\n c: Context<E>\n): Response | Promise<Response> {\n const requestId = c.get('requestId');\n const servingData = `${c.req.method}: ${c.req.url}`;\n const details = Details.new().requestInfo({ requestId, servingData });\n\n if (error instanceof StatusError) {\n error.body?.error?.details?.push(...details.list);\n return c.json(error.body, error.status as ContentfulStatusCode);\n }\n\n console.
|
|
1
|
+
{"version":3,"sources":["../../src/hono/handler.ts"],"sourcesContent":["import type { Context } from 'hono';\nimport type { HTTPResponseError, Bindings } from 'hono/types';\nimport type { ContentfulStatusCode } from 'hono/utils/http-status';\nimport type { RequestIdVariables } from 'hono/request-id';\nimport { Status, StatusError } from '../status';\nimport { Details } from '../detail';\n\ntype Env = {\n Variables: RequestIdVariables;\n Bindings?: Bindings;\n};\n\nexport function errorHandler<E extends Env = any>(\n error: Error | HTTPResponseError,\n c: Context<E>\n): Response | Promise<Response> {\n const requestId = c.get('requestId');\n const servingData = `${c.req.method}: ${c.req.url}`;\n const details = Details.new().requestInfo({ requestId, servingData });\n\n if (error instanceof StatusError) {\n error.body?.error?.details?.push(...details.list);\n return c.json(error.body, error.status as ContentfulStatusCode);\n }\n\n console.error(error);\n return Status.internal('Unknown error').response(details);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAoC;AACpC,oBAAwB;AAOjB,SAAS,aACd,OACA,GAC8B;AAC9B,QAAM,YAAY,EAAE,IAAI,WAAW;AACnC,QAAM,cAAc,GAAG,EAAE,IAAI,MAAM,KAAK,EAAE,IAAI,GAAG;AACjD,QAAM,UAAU,sBAAQ,IAAI,EAAE,YAAY,EAAE,WAAW,YAAY,CAAC;AAEpE,MAAI,iBAAiB,2BAAa;AAChC,UAAM,MAAM,OAAO,SAAS,KAAK,GAAG,QAAQ,IAAI;AAChD,WAAO,EAAE,KAAK,MAAM,MAAM,MAAM,MAA8B;AAAA,EAChE;AAEA,UAAQ,MAAM,KAAK;AACnB,SAAO,qBAAO,SAAS,eAAe,EAAE,SAAS,OAAO;AAC1D;","names":[]}
|
package/dist/hono/handler.mjs
CHANGED
|
@@ -9,7 +9,7 @@ function errorHandler(error, c) {
|
|
|
9
9
|
error.body?.error?.details?.push(...details.list);
|
|
10
10
|
return c.json(error.body, error.status);
|
|
11
11
|
}
|
|
12
|
-
console.
|
|
12
|
+
console.error(error);
|
|
13
13
|
return Status.internal("Unknown error").response(details);
|
|
14
14
|
}
|
|
15
15
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/handler.ts"],"sourcesContent":["import type { Context } from 'hono';\nimport type { HTTPResponseError, Bindings } from 'hono/types';\nimport type { ContentfulStatusCode } from 'hono/utils/http-status';\nimport type { RequestIdVariables } from 'hono/request-id';\nimport { Status, StatusError } from '../status';\nimport { Details } from '../detail';\n\ntype Env = {\n Variables: RequestIdVariables;\n Bindings?: Bindings;\n};\n\nexport function errorHandler<E extends Env = any>(\n error: Error | HTTPResponseError,\n c: Context<E>\n): Response | Promise<Response> {\n const requestId = c.get('requestId');\n const servingData = `${c.req.method}: ${c.req.url}`;\n const details = Details.new().requestInfo({ requestId, servingData });\n\n if (error instanceof StatusError) {\n error.body?.error?.details?.push(...details.list);\n return c.json(error.body, error.status as ContentfulStatusCode);\n }\n\n console.
|
|
1
|
+
{"version":3,"sources":["../../src/hono/handler.ts"],"sourcesContent":["import type { Context } from 'hono';\nimport type { HTTPResponseError, Bindings } from 'hono/types';\nimport type { ContentfulStatusCode } from 'hono/utils/http-status';\nimport type { RequestIdVariables } from 'hono/request-id';\nimport { Status, StatusError } from '../status';\nimport { Details } from '../detail';\n\ntype Env = {\n Variables: RequestIdVariables;\n Bindings?: Bindings;\n};\n\nexport function errorHandler<E extends Env = any>(\n error: Error | HTTPResponseError,\n c: Context<E>\n): Response | Promise<Response> {\n const requestId = c.get('requestId');\n const servingData = `${c.req.method}: ${c.req.url}`;\n const details = Details.new().requestInfo({ requestId, servingData });\n\n if (error instanceof StatusError) {\n error.body?.error?.details?.push(...details.list);\n return c.json(error.body, error.status as ContentfulStatusCode);\n }\n\n console.error(error);\n return Status.internal('Unknown error').response(details);\n}\n"],"mappings":";AAIA,SAAS,QAAQ,mBAAmB;AACpC,SAAS,eAAe;AAOjB,SAAS,aACd,OACA,GAC8B;AAC9B,QAAM,YAAY,EAAE,IAAI,WAAW;AACnC,QAAM,cAAc,GAAG,EAAE,IAAI,MAAM,KAAK,EAAE,IAAI,GAAG;AACjD,QAAM,UAAU,QAAQ,IAAI,EAAE,YAAY,EAAE,WAAW,YAAY,CAAC;AAEpE,MAAI,iBAAiB,aAAa;AAChC,UAAM,MAAM,OAAO,SAAS,KAAK,GAAG,QAAQ,IAAI;AAChD,WAAO,EAAE,KAAK,MAAM,MAAM,MAAM,MAA8B;AAAA,EAChE;AAEA,UAAQ,MAAM,KAAK;AACnB,SAAO,OAAO,SAAS,eAAe,EAAE,SAAS,OAAO;AAC1D;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shware/http",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
],
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/jest": "^29.5.14",
|
|
33
|
-
"@types/node": "^22.13.
|
|
33
|
+
"@types/node": "^22.13.13",
|
|
34
34
|
"jest": "^29.7.0",
|
|
35
|
-
"ts-jest": "^29.
|
|
36
|
-
"typescript": "5.8.2"
|
|
35
|
+
"ts-jest": "^29.3.0",
|
|
36
|
+
"typescript": "^5.8.2"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"zod": "^3.24.2"
|