@shware/http 0.2.9 → 0.2.11

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,40 +20,43 @@ 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
+ 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
+ }
28
44
  return {
29
- ip: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip"),
30
- city: c.req.header("cf-ipcity"),
31
- country: c.req.header("cf-ipcountry"),
32
- continent: c.req.header("cf-ipcontinent"),
33
- longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : void 0,
34
- latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) : void 0,
35
- region: c.req.header("cf-region"),
36
- region_code: c.req.header("cf-region-code"),
37
- metro_code: c.req.header("cf-metro-code"),
38
- postal_code: c.req.header("cf-postal-code"),
39
- timezone: c.req.header("cf-timezone")
40
- };
41
- }
42
- function geolocationVercel(c) {
43
- return {
44
- ip: c.req.header("x-real-ip"),
45
- city: c.req.header("x-vercel-ip-city"),
46
- country: c.req.header("x-vercel-ip-country"),
47
- continent: c.req.header("x-vercel-ip-continent"),
48
- longitude: c.req.header("x-vercel-ip-longitude") ? Number(c.req.header("x-vercel-ip-longitude")) : void 0,
49
- latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) : void 0,
50
- region_code: c.req.header("x-vercel-ip-country-region"),
51
- postal_code: c.req.header("x-vercel-ip-postal-code")
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: null,
52
+ region_code: c.req.header("x-vercel-ip-country-region") ?? null,
53
+ metro_code: null,
54
+ postal_code: c.req.header("x-vercel-ip-postal-code") ?? null,
55
+ timezone: null
52
56
  };
53
57
  }
54
58
  // Annotate the CommonJS export names for ESM import in node:
55
59
  0 && (module.exports = {
56
- geolocation,
57
- geolocationVercel
60
+ geolocation
58
61
  });
59
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;\n city?: string;\n country?: string;\n continent?: string;\n longitude?: number;\n latitude?: number;\n region?: string;\n region_code?: string;\n metro_code?: string;\n postal_code?: string;\n timezone?: string;\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'),\n city: c.req.header('cf-ipcity'),\n country: c.req.header('cf-ipcountry'),\n continent: c.req.header('cf-ipcontinent'),\n longitude: c.req.header('cf-iplongitude') ? Number(c.req.header('cf-iplongitude')) : undefined,\n latitude: c.req.header('cf-iplatitude') ? Number(c.req.header('cf-iplatitude')) : undefined,\n region: c.req.header('cf-region'),\n region_code: c.req.header('cf-region-code'),\n metro_code: c.req.header('cf-metro-code'),\n postal_code: c.req.header('cf-postal-code'),\n timezone: c.req.header('cf-timezone'),\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'),\n city: c.req.header('x-vercel-ip-city'),\n country: c.req.header('x-vercel-ip-country'),\n continent: c.req.header('x-vercel-ip-continent'),\n longitude: c.req.header('x-vercel-ip-longitude')\n ? Number(c.req.header('x-vercel-ip-longitude'))\n : undefined,\n latitude: c.req.header('x-vercel-ip-latitude')\n ? Number(c.req.header('x-vercel-ip-latitude'))\n : undefined,\n region_code: c.req.header('x-vercel-ip-country-region'),\n postal_code: c.req.header('x-vercel-ip-postal-code'),\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;AAAA,IACrE,MAAM,EAAE,IAAI,OAAO,WAAW;AAAA,IAC9B,SAAS,EAAE,IAAI,OAAO,cAAc;AAAA,IACpC,WAAW,EAAE,IAAI,OAAO,gBAAgB;AAAA,IACxC,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;AAAA,IAChC,aAAa,EAAE,IAAI,OAAO,gBAAgB;AAAA,IAC1C,YAAY,EAAE,IAAI,OAAO,eAAe;AAAA,IACxC,aAAa,EAAE,IAAI,OAAO,gBAAgB;AAAA,IAC1C,UAAU,EAAE,IAAI,OAAO,aAAa;AAAA,EACtC;AACF;AAGO,SAAS,kBAAkB,GAAyB;AACzD,SAAO;AAAA,IACL,IAAI,EAAE,IAAI,OAAO,WAAW;AAAA,IAC5B,MAAM,EAAE,IAAI,OAAO,kBAAkB;AAAA,IACrC,SAAS,EAAE,IAAI,OAAO,qBAAqB;AAAA,IAC3C,WAAW,EAAE,IAAI,OAAO,uBAAuB;AAAA,IAC/C,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,aAAa,EAAE,IAAI,OAAO,4BAA4B;AAAA,IACtD,aAAa,EAAE,IAAI,OAAO,yBAAyB;AAAA,EACrD;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":[]}
@@ -1,21 +1,18 @@
1
1
  import { Context } from 'hono';
2
2
 
3
3
  type Geolocation = {
4
- ip?: string;
5
- city?: string;
6
- country?: string;
7
- continent?: string;
8
- longitude?: number;
9
- latitude?: number;
10
- region?: string;
11
- region_code?: string;
12
- metro_code?: string;
13
- postal_code?: string;
14
- timezone?: string;
4
+ ip: string | null;
5
+ city: string | null;
6
+ country: string | null;
7
+ continent: string | null;
8
+ longitude: number | null;
9
+ latitude: number | null;
10
+ region: string | null;
11
+ region_code: string | null;
12
+ metro_code: string | null;
13
+ postal_code: string | null;
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,21 +1,18 @@
1
1
  import { Context } from 'hono';
2
2
 
3
3
  type Geolocation = {
4
- ip?: string;
5
- city?: string;
6
- country?: string;
7
- continent?: string;
8
- longitude?: number;
9
- latitude?: number;
10
- region?: string;
11
- region_code?: string;
12
- metro_code?: string;
13
- postal_code?: string;
14
- timezone?: string;
4
+ ip: string | null;
5
+ city: string | null;
6
+ country: string | null;
7
+ continent: string | null;
8
+ longitude: number | null;
9
+ latitude: number | null;
10
+ region: string | null;
11
+ region_code: string | null;
12
+ metro_code: string | null;
13
+ postal_code: string | null;
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,33 +1,37 @@
1
1
  // src/hono/geolocation.ts
2
+ import { getRuntimeKey } from "hono/adapter";
2
3
  function geolocation(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
+ }
3
20
  return {
4
- ip: c.req.header("true-client-ip") ?? c.req.header("cf-connecting-ip"),
5
- city: c.req.header("cf-ipcity"),
6
- country: c.req.header("cf-ipcountry"),
7
- continent: c.req.header("cf-ipcontinent"),
8
- longitude: c.req.header("cf-iplongitude") ? Number(c.req.header("cf-iplongitude")) : void 0,
9
- latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) : void 0,
10
- region: c.req.header("cf-region"),
11
- region_code: c.req.header("cf-region-code"),
12
- metro_code: c.req.header("cf-metro-code"),
13
- postal_code: c.req.header("cf-postal-code"),
14
- timezone: c.req.header("cf-timezone")
15
- };
16
- }
17
- function geolocationVercel(c) {
18
- return {
19
- ip: c.req.header("x-real-ip"),
20
- city: c.req.header("x-vercel-ip-city"),
21
- country: c.req.header("x-vercel-ip-country"),
22
- continent: c.req.header("x-vercel-ip-continent"),
23
- longitude: c.req.header("x-vercel-ip-longitude") ? Number(c.req.header("x-vercel-ip-longitude")) : void 0,
24
- latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) : void 0,
25
- region_code: c.req.header("x-vercel-ip-country-region"),
26
- postal_code: c.req.header("x-vercel-ip-postal-code")
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: null,
28
+ region_code: c.req.header("x-vercel-ip-country-region") ?? null,
29
+ metro_code: null,
30
+ postal_code: c.req.header("x-vercel-ip-postal-code") ?? null,
31
+ timezone: null
27
32
  };
28
33
  }
29
34
  export {
30
- geolocation,
31
- geolocationVercel
35
+ geolocation
32
36
  };
33
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;\n city?: string;\n country?: string;\n continent?: string;\n longitude?: number;\n latitude?: number;\n region?: string;\n region_code?: string;\n metro_code?: string;\n postal_code?: string;\n timezone?: string;\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'),\n city: c.req.header('cf-ipcity'),\n country: c.req.header('cf-ipcountry'),\n continent: c.req.header('cf-ipcontinent'),\n longitude: c.req.header('cf-iplongitude') ? Number(c.req.header('cf-iplongitude')) : undefined,\n latitude: c.req.header('cf-iplatitude') ? Number(c.req.header('cf-iplatitude')) : undefined,\n region: c.req.header('cf-region'),\n region_code: c.req.header('cf-region-code'),\n metro_code: c.req.header('cf-metro-code'),\n postal_code: c.req.header('cf-postal-code'),\n timezone: c.req.header('cf-timezone'),\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'),\n city: c.req.header('x-vercel-ip-city'),\n country: c.req.header('x-vercel-ip-country'),\n continent: c.req.header('x-vercel-ip-continent'),\n longitude: c.req.header('x-vercel-ip-longitude')\n ? Number(c.req.header('x-vercel-ip-longitude'))\n : undefined,\n latitude: c.req.header('x-vercel-ip-latitude')\n ? Number(c.req.header('x-vercel-ip-latitude'))\n : undefined,\n region_code: c.req.header('x-vercel-ip-country-region'),\n postal_code: c.req.header('x-vercel-ip-postal-code'),\n };\n}\n"],"mappings":";AAiBO,SAAS,YAAY,GAAyB;AACnD,SAAO;AAAA,IACL,IAAI,EAAE,IAAI,OAAO,gBAAgB,KAAK,EAAE,IAAI,OAAO,kBAAkB;AAAA,IACrE,MAAM,EAAE,IAAI,OAAO,WAAW;AAAA,IAC9B,SAAS,EAAE,IAAI,OAAO,cAAc;AAAA,IACpC,WAAW,EAAE,IAAI,OAAO,gBAAgB;AAAA,IACxC,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;AAAA,IAChC,aAAa,EAAE,IAAI,OAAO,gBAAgB;AAAA,IAC1C,YAAY,EAAE,IAAI,OAAO,eAAe;AAAA,IACxC,aAAa,EAAE,IAAI,OAAO,gBAAgB;AAAA,IAC1C,UAAU,EAAE,IAAI,OAAO,aAAa;AAAA,EACtC;AACF;AAGO,SAAS,kBAAkB,GAAyB;AACzD,SAAO;AAAA,IACL,IAAI,EAAE,IAAI,OAAO,WAAW;AAAA,IAC5B,MAAM,EAAE,IAAI,OAAO,kBAAkB;AAAA,IACrC,SAAS,EAAE,IAAI,OAAO,qBAAqB;AAAA,IAC3C,WAAW,EAAE,IAAI,OAAO,uBAAuB;AAAA,IAC/C,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,aAAa,EAAE,IAAI,OAAO,4BAA4B;AAAA,IACtD,aAAa,EAAE,IAAI,OAAO,yBAAyB;AAAA,EACrD;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,SAAS,qBAAqB;AAiBvB,SAAS,YAAY,GAAyB;AACnD,QAAM,UAAU,cAAc;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":[]}
@@ -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,7 @@
1
1
  {
2
2
  "name": "@shware/http",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
+ "private": false,
4
5
  "type": "module",
5
6
  "scripts": {
6
7
  "dev": "tsc --watch",