@shware/http 0.2.10 → 0.2.12

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.
@@ -20,26 +20,27 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/hono/geolocation.ts
21
21
  var geolocation_exports = {};
22
22
  __export(geolocation_exports, {
23
- geolocation: () => geolocation,
24
- geolocationVercel: () => geolocationVercel
23
+ geolocation: () => geolocation
25
24
  });
26
25
  module.exports = __toCommonJS(geolocation_exports);
26
+ var import_adapter = require("hono/adapter");
27
27
  function geolocation(c) {
28
- return {
29
- ip: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip") ?? null,
30
- city: c.req.header("cf-ipcity") ?? null,
31
- country: c.req.header("cf-ipcountry") ?? null,
32
- continent: c.req.header("cf-ipcontinent") ?? null,
33
- longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : null,
34
- latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) : null,
35
- region: c.req.header("cf-region") ?? null,
36
- region_code: c.req.header("cf-region-code") ?? null,
37
- metro_code: c.req.header("cf-metro-code") ?? null,
38
- postal_code: c.req.header("cf-postal-code") ?? null,
39
- timezone: c.req.header("cf-timezone") ?? null
40
- };
41
- }
42
- function geolocationVercel(c) {
28
+ const runtime = (0, import_adapter.getRuntimeKey)();
29
+ if (runtime === "workerd") {
30
+ return {
31
+ ip: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip") ?? null,
32
+ city: c.req.header("cf-ipcity") ?? null,
33
+ country: c.req.header("cf-ipcountry") ?? null,
34
+ continent: c.req.header("cf-ipcontinent") ?? null,
35
+ longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : null,
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,
39
+ metro_code: c.req.header("cf-metro-code") ?? null,
40
+ postal_code: c.req.header("cf-postal-code") ?? null,
41
+ timezone: c.req.header("cf-timezone") ?? null
42
+ };
43
+ }
43
44
  return {
44
45
  ip: c.req.header("x-real-ip") ?? null,
45
46
  city: c.req.header("x-vercel-ip-city") ?? null,
@@ -56,7 +57,6 @@ function geolocationVercel(c) {
56
57
  }
57
58
  // Annotate the CommonJS export names for ESM import in node:
58
59
  0 && (module.exports = {
59
- geolocation,
60
- geolocationVercel
60
+ geolocation
61
61
  });
62
62
  //# sourceMappingURL=geolocation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import type { Context } from 'hono';\n\nexport type Geolocation = {\n ip: string | null;\n city: string | null;\n country: string | null;\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null;\n region_code: string | null;\n metro_code: string | null;\n postal_code: string | null;\n timezone: string | null;\n};\n\n/** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */\nexport function geolocation(c: Context): Geolocation {\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') ?? null,\n region_code: 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 */\nexport function geolocationVercel(c: Context): Geolocation {\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: null,\n region_code: 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,YAAY,GAAyB;AACnD,SAAO;AAAA,IACL,IAAI,EAAE,IAAI,OAAO,gBAAgB,KAAK,EAAE,IAAI,OAAO,kBAAkB,KAAK;AAAA,IAC1E,MAAM,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,IACnC,SAAS,EAAE,IAAI,OAAO,cAAc,KAAK;AAAA,IACzC,WAAW,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC7C,WAAW,EAAE,IAAI,OAAO,gBAAgB,IAAI,OAAO,EAAE,IAAI,OAAO,gBAAgB,CAAC,IAAI;AAAA,IACrF,UAAU,EAAE,IAAI,OAAO,eAAe,IAAI,OAAO,EAAE,IAAI,OAAO,eAAe,CAAC,IAAI;AAAA,IAClF,QAAQ,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,IACrC,aAAa,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC/C,YAAY,EAAE,IAAI,OAAO,eAAe,KAAK;AAAA,IAC7C,aAAa,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,IAC/C,UAAU,EAAE,IAAI,OAAO,aAAa,KAAK;AAAA,EAC3C;AACF;AAGO,SAAS,kBAAkB,GAAyB;AACzD,SAAO;AAAA,IACL,IAAI,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,IACjC,MAAM,EAAE,IAAI,OAAO,kBAAkB,KAAK;AAAA,IAC1C,SAAS,EAAE,IAAI,OAAO,qBAAqB,KAAK;AAAA,IAChD,WAAW,EAAE,IAAI,OAAO,uBAAuB,KAAK;AAAA,IACpD,WAAW,EAAE,IAAI,OAAO,uBAAuB,IAC3C,OAAO,EAAE,IAAI,OAAO,uBAAuB,CAAC,IAC5C;AAAA,IACJ,UAAU,EAAE,IAAI,OAAO,sBAAsB,IACzC,OAAO,EAAE,IAAI,OAAO,sBAAsB,CAAC,IAC3C;AAAA,IACJ,QAAQ;AAAA,IACR,aAAa,EAAE,IAAI,OAAO,4BAA4B,KAAK;AAAA,IAC3D,YAAY;AAAA,IACZ,aAAa,EAAE,IAAI,OAAO,yBAAyB,KAAK;AAAA,IACxD,UAAU;AAAA,EACZ;AACF;","names":[]}
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;\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null;\n region_code: string | null;\n metro_code: string | null;\n postal_code: string | null;\n timezone: string | null;\n};\n\nexport function geolocation(c: Context): Geolocation {\n const runtime = getRuntimeKey();\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') ?? null,\n region_code: 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 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: null,\n region_code: 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAiBvB,SAAS,YAAY,GAAyB;AACnD,QAAM,cAAU,8BAAc;AAE9B,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,EAAE,IAAI,OAAO,gBAAgB,CAAC,IAAI;AAAA,MACrF,UAAU,EAAE,IAAI,OAAO,eAAe,IAAI,OAAO,EAAE,IAAI,OAAO,eAAe,CAAC,IAAI;AAAA,MAClF,QAAQ,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,MACrC,aAAa,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,MAC/C,YAAY,EAAE,IAAI,OAAO,eAAe,KAAK;AAAA,MAC7C,aAAa,EAAE,IAAI,OAAO,gBAAgB,KAAK;AAAA,MAC/C,UAAU,EAAE,IAAI,OAAO,aAAa,KAAK;AAAA,IAC3C;AAAA,EACF;AAGA,SAAO;AAAA,IACL,IAAI,EAAE,IAAI,OAAO,WAAW,KAAK;AAAA,IACjC,MAAM,EAAE,IAAI,OAAO,kBAAkB,KAAK;AAAA,IAC1C,SAAS,EAAE,IAAI,OAAO,qBAAqB,KAAK;AAAA,IAChD,WAAW,EAAE,IAAI,OAAO,uBAAuB,KAAK;AAAA,IACpD,WAAW,EAAE,IAAI,OAAO,uBAAuB,IAC3C,OAAO,EAAE,IAAI,OAAO,uBAAuB,CAAC,IAC5C;AAAA,IACJ,UAAU,EAAE,IAAI,OAAO,sBAAsB,IACzC,OAAO,EAAE,IAAI,OAAO,sBAAsB,CAAC,IAC3C;AAAA,IACJ,QAAQ;AAAA,IACR,aAAa,EAAE,IAAI,OAAO,4BAA4B,KAAK;AAAA,IAC3D,YAAY;AAAA,IACZ,aAAa,EAAE,IAAI,OAAO,yBAAyB,KAAK;AAAA,IACxD,UAAU;AAAA,EACZ;AACF;","names":[]}
@@ -13,9 +13,6 @@ type Geolocation = {
13
13
  postal_code: string | null;
14
14
  timezone: string | null;
15
15
  };
16
- /** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */
17
16
  declare function geolocation(c: Context): Geolocation;
18
- /** https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts */
19
- declare function geolocationVercel(c: Context): Geolocation;
20
17
 
21
- export { type Geolocation, geolocation, geolocationVercel };
18
+ export { type Geolocation, geolocation };
@@ -13,9 +13,6 @@ type Geolocation = {
13
13
  postal_code: string | null;
14
14
  timezone: string | null;
15
15
  };
16
- /** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */
17
16
  declare function geolocation(c: Context): Geolocation;
18
- /** https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts */
19
- declare function geolocationVercel(c: Context): Geolocation;
20
17
 
21
- export { type Geolocation, geolocation, geolocationVercel };
18
+ export { type Geolocation, geolocation };
@@ -1,20 +1,22 @@
1
1
  // src/hono/geolocation.ts
2
+ import { getRuntimeKey } from "hono/adapter";
2
3
  function geolocation(c) {
3
- return {
4
- ip: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip") ?? null,
5
- city: c.req.header("cf-ipcity") ?? null,
6
- country: c.req.header("cf-ipcountry") ?? null,
7
- continent: c.req.header("cf-ipcontinent") ?? null,
8
- longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : null,
9
- latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) : null,
10
- region: c.req.header("cf-region") ?? null,
11
- region_code: c.req.header("cf-region-code") ?? null,
12
- metro_code: c.req.header("cf-metro-code") ?? null,
13
- postal_code: c.req.header("cf-postal-code") ?? null,
14
- timezone: c.req.header("cf-timezone") ?? null
15
- };
16
- }
17
- function geolocationVercel(c) {
4
+ const runtime = getRuntimeKey();
5
+ if (runtime === "workerd") {
6
+ return {
7
+ ip: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip") ?? null,
8
+ city: c.req.header("cf-ipcity") ?? null,
9
+ country: c.req.header("cf-ipcountry") ?? null,
10
+ continent: c.req.header("cf-ipcontinent") ?? null,
11
+ longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : null,
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,
15
+ metro_code: c.req.header("cf-metro-code") ?? null,
16
+ postal_code: c.req.header("cf-postal-code") ?? null,
17
+ timezone: c.req.header("cf-timezone") ?? null
18
+ };
19
+ }
18
20
  return {
19
21
  ip: c.req.header("x-real-ip") ?? null,
20
22
  city: c.req.header("x-vercel-ip-city") ?? null,
@@ -30,7 +32,6 @@ function geolocationVercel(c) {
30
32
  };
31
33
  }
32
34
  export {
33
- geolocation,
34
- geolocationVercel
35
+ geolocation
35
36
  };
36
37
  //# sourceMappingURL=geolocation.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import type { Context } from 'hono';\n\nexport type Geolocation = {\n ip: string | null;\n city: string | null;\n country: string | null;\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null;\n region_code: string | null;\n metro_code: string | null;\n postal_code: string | null;\n timezone: string | null;\n};\n\n/** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */\nexport function geolocation(c: Context): Geolocation {\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') ?? null,\n region_code: 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 */\nexport function geolocationVercel(c: Context): Geolocation {\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: null,\n region_code: 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"],"mappings":";AAiBO,SAAS,YAAY,G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Z,aAAa,EAAE,IAAI,OAAO,yBAAyB,KAAK;AAAA,IACxD,UAAU;AAAA,EACZ;AACF;","names":[]}
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;\n continent: string | null;\n longitude: number | null;\n latitude: number | null;\n region: string | null;\n region_code: string | null;\n metro_code: string | null;\n postal_code: string | null;\n timezone: string | null;\n};\n\nexport function geolocation(c: Context): Geolocation {\n const runtime = getRuntimeKey();\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') ?? null,\n region_code: 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 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: null,\n region_code: c.req.header('x-vercel-ip-country-region') ?? null,\n metro_code: null,\n postal_code: c.req.header('x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O,sBAAsB,CAAC,IAC3C;AAAA,IACJ,QAAQ;AAAA,IACR,aAAa,EAAE,IAAI,OAAO,4BAA4B,KAAK;AAAA,IAC3D,YAAY;AAAA,IACZ,aAAa,EAAE,IAAI,OAAO,yBAAyB,KAAK;AAAA,IACxD,UAAU;AAAA,EACZ;AACF;","names":[]}
@@ -26,14 +26,15 @@ module.exports = __toCommonJS(handler_exports);
26
26
  var import_status = require("../status.cjs");
27
27
  var import_detail = require("../detail.cjs");
28
28
  function errorHandler(error, c) {
29
+ const requestId = c.get("requestId");
30
+ const servingData = `${c.req.method}: ${c.req.url}`;
31
+ const details = import_detail.Details.new().requestInfo({ requestId, servingData });
29
32
  if (error instanceof import_status.StatusError) {
30
- const requestId = c.get("requestId");
31
- const servingData = `${c.req.method}: ${c.req.url}`;
32
- const details = import_detail.Details.new().requestInfo({ requestId, servingData });
33
33
  error.body?.error?.details?.push(...details.list);
34
34
  return c.json(error.body, error.status);
35
35
  }
36
- return c.json(import_status.Status.internal(error.message).response(), 500);
36
+ console.log("Unknown error:", error);
37
+ return import_status.Status.internal("Unknown error").response(details);
37
38
  }
38
39
  // Annotate the CommonJS export names for ESM import in node:
39
40
  0 && (module.exports = {
@@ -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 if (error instanceof StatusError) {\n const requestId = c.get('requestId');\n const servingData = `${c.req.method}: ${c.req.url}`;\n const details = Details.new().requestInfo({ requestId, servingData });\n error.body?.error?.details?.push(...details.list);\n return c.json(error.body, error.status as ContentfulStatusCode);\n }\n\n return c.json(Status.internal(error.message).response(), 500);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAoC;AACpC,oBAAwB;AAOjB,SAAS,aACd,OACA,GAC8B;AAC9B,MAAI,iBAAiB,2BAAa;AAChC,UAAM,YAAY,EAAE,IAAI,WAAW;AACnC,UAAM,cAAc,GAAG,EAAE,IAAI,MAAM,KAAK,EAAE,IAAI,GAAG;AACjD,UAAM,UAAU,sBAAQ,IAAI,EAAE,YAAY,EAAE,WAAW,YAAY,CAAC;AACpE,UAAM,MAAM,OAAO,SAAS,KAAK,GAAG,QAAQ,IAAI;AAChD,WAAO,EAAE,KAAK,MAAM,MAAM,MAAM,MAA8B;AAAA,EAChE;AAEA,SAAO,EAAE,KAAK,qBAAO,SAAS,MAAM,OAAO,EAAE,SAAS,GAAG,GAAG;AAC9D;","names":[]}
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.log('Unknown 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,IAAI,kBAAkB,KAAK;AACnC,SAAO,qBAAO,SAAS,eAAe,EAAE,SAAS,OAAO;AAC1D;","names":[]}
@@ -2,14 +2,15 @@
2
2
  import { Status, StatusError } from "../status.mjs";
3
3
  import { Details } from "../detail.mjs";
4
4
  function errorHandler(error, c) {
5
+ const requestId = c.get("requestId");
6
+ const servingData = `${c.req.method}: ${c.req.url}`;
7
+ const details = Details.new().requestInfo({ requestId, servingData });
5
8
  if (error instanceof StatusError) {
6
- const requestId = c.get("requestId");
7
- const servingData = `${c.req.method}: ${c.req.url}`;
8
- const details = Details.new().requestInfo({ requestId, servingData });
9
9
  error.body?.error?.details?.push(...details.list);
10
10
  return c.json(error.body, error.status);
11
11
  }
12
- return c.json(Status.internal(error.message).response(), 500);
12
+ console.log("Unknown error:", error);
13
+ return Status.internal("Unknown error").response(details);
13
14
  }
14
15
  export {
15
16
  errorHandler
@@ -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 if (error instanceof StatusError) {\n const requestId = c.get('requestId');\n const servingData = `${c.req.method}: ${c.req.url}`;\n const details = Details.new().requestInfo({ requestId, servingData });\n error.body?.error?.details?.push(...details.list);\n return c.json(error.body, error.status as ContentfulStatusCode);\n }\n\n return c.json(Status.internal(error.message).response(), 500);\n}\n"],"mappings":";AAIA,SAAS,QAAQ,mBAAmB;AACpC,SAAS,eAAe;AAOjB,SAAS,aACd,OACA,GAC8B;AAC9B,MAAI,iBAAiB,aAAa;AAChC,UAAM,YAAY,EAAE,IAAI,WAAW;AACnC,UAAM,cAAc,GAAG,EAAE,IAAI,MAAM,KAAK,EAAE,IAAI,GAAG;AACjD,UAAM,UAAU,QAAQ,IAAI,EAAE,YAAY,EAAE,WAAW,YAAY,CAAC;AACpE,UAAM,MAAM,OAAO,SAAS,KAAK,GAAG,QAAQ,IAAI;AAChD,WAAO,EAAE,KAAK,MAAM,MAAM,MAAM,MAA8B;AAAA,EAChE;AAEA,SAAO,EAAE,KAAK,OAAO,SAAS,MAAM,OAAO,EAAE,SAAS,GAAG,GAAG;AAC9D;","names":[]}
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.log('Unknown 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,IAAI,kBAAkB,KAAK;AACnC,SAAO,OAAO,SAAS,eAAe,EAAE,SAAS,OAAO;AAC1D;","names":[]}
@@ -22,7 +22,6 @@ var hono_exports = {};
22
22
  __export(hono_exports, {
23
23
  errorHandler: () => import_handler.errorHandler,
24
24
  geolocation: () => import_geolocation.geolocation,
25
- geolocationVercel: () => import_geolocation.geolocationVercel,
26
25
  zValidator: () => import_validator.zValidator
27
26
  });
28
27
  module.exports = __toCommonJS(hono_exports);
@@ -33,7 +32,6 @@ var import_geolocation = require("./geolocation.cjs");
33
32
  0 && (module.exports = {
34
33
  errorHandler,
35
34
  geolocation,
36
- geolocationVercel,
37
35
  zValidator
38
36
  });
39
37
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation, geolocationVercel } from './geolocation';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2B;AAC3B,qBAA6B;AAC7B,yBAA+C;","names":[]}
1
+ {"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2B;AAC3B,qBAA6B;AAC7B,yBAA4B;","names":[]}
@@ -1,6 +1,6 @@
1
1
  export { zValidator } from './validator.cjs';
2
2
  export { errorHandler } from './handler.cjs';
3
- export { geolocation, geolocationVercel } from './geolocation.cjs';
3
+ export { geolocation } from './geolocation.cjs';
4
4
  import 'hono/utils/headers';
5
5
  import 'hono/types';
6
6
  import 'hono';
@@ -1,6 +1,6 @@
1
1
  export { zValidator } from './validator.js';
2
2
  export { errorHandler } from './handler.js';
3
- export { geolocation, geolocationVercel } from './geolocation.js';
3
+ export { geolocation } from './geolocation.js';
4
4
  import 'hono/utils/headers';
5
5
  import 'hono/types';
6
6
  import 'hono';
@@ -1,11 +1,10 @@
1
1
  // src/hono/index.ts
2
2
  import { zValidator } from "./validator.mjs";
3
3
  import { errorHandler } from "./handler.mjs";
4
- import { geolocation, geolocationVercel } from "./geolocation.mjs";
4
+ import { geolocation } from "./geolocation.mjs";
5
5
  export {
6
6
  errorHandler,
7
7
  geolocation,
8
- geolocationVercel,
9
8
  zValidator
10
9
  };
11
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation, geolocationVercel } from './geolocation';\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,aAAa,yBAAyB;","names":[]}
1
+ {"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation } from './geolocation';\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shware/http",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {