@shware/http 0.2.9 → 0.2.10
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.
|
@@ -26,29 +26,32 @@ __export(geolocation_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(geolocation_exports);
|
|
27
27
|
function geolocation(c) {
|
|
28
28
|
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")) :
|
|
34
|
-
latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) :
|
|
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")
|
|
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
40
|
};
|
|
41
41
|
}
|
|
42
42
|
function geolocationVercel(c) {
|
|
43
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")) :
|
|
49
|
-
latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) :
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
ip: c.req.header("x-real-ip") ?? null,
|
|
45
|
+
city: c.req.header("x-vercel-ip-city") ?? null,
|
|
46
|
+
country: c.req.header("x-vercel-ip-country") ?? null,
|
|
47
|
+
continent: c.req.header("x-vercel-ip-continent") ?? null,
|
|
48
|
+
longitude: c.req.header("x-vercel-ip-longitude") ? Number(c.req.header("x-vercel-ip-longitude")) : null,
|
|
49
|
+
latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) : null,
|
|
50
|
+
region: null,
|
|
51
|
+
region_code: 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
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import type { Context } from 'hono';\n\nexport type Geolocation = {\n ip
|
|
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,WAA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-
country
|
|
7
|
-
continent
|
|
8
|
-
longitude
|
|
9
|
-
latitude
|
|
10
|
-
region
|
|
11
|
-
region_code
|
|
12
|
-
metro_code
|
|
13
|
-
postal_code
|
|
14
|
-
timezone
|
|
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
16
|
/** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */
|
|
17
17
|
declare function geolocation(c: Context): Geolocation;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
2
|
|
|
3
3
|
type Geolocation = {
|
|
4
|
-
ip
|
|
5
|
-
city
|
|
6
|
-
country
|
|
7
|
-
continent
|
|
8
|
-
longitude
|
|
9
|
-
latitude
|
|
10
|
-
region
|
|
11
|
-
region_code
|
|
12
|
-
metro_code
|
|
13
|
-
postal_code
|
|
14
|
-
timezone
|
|
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
16
|
/** reference: https://developers.cloudflare.com/rules/transform/managed-transforms/reference/#add-visitor-location-headers */
|
|
17
17
|
declare function geolocation(c: Context): Geolocation;
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
// src/hono/geolocation.ts
|
|
2
2
|
function geolocation(c) {
|
|
3
3
|
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")) :
|
|
9
|
-
latitude: c.req.header("cf-iplatitude") ? Number(c.req.header("cf-iplatitude")) :
|
|
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")
|
|
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
15
|
};
|
|
16
16
|
}
|
|
17
17
|
function geolocationVercel(c) {
|
|
18
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")) :
|
|
24
|
-
latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) :
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
ip: c.req.header("x-real-ip") ?? null,
|
|
20
|
+
city: c.req.header("x-vercel-ip-city") ?? null,
|
|
21
|
+
country: c.req.header("x-vercel-ip-country") ?? null,
|
|
22
|
+
continent: c.req.header("x-vercel-ip-continent") ?? null,
|
|
23
|
+
longitude: c.req.header("x-vercel-ip-longitude") ? Number(c.req.header("x-vercel-ip-longitude")) : null,
|
|
24
|
+
latitude: c.req.header("x-vercel-ip-latitude") ? Number(c.req.header("x-vercel-ip-latitude")) : null,
|
|
25
|
+
region: null,
|
|
26
|
+
region_code: c.req.header("x-vercel-ip-country-region") ?? null,
|
|
27
|
+
metro_code: null,
|
|
28
|
+
postal_code: c.req.header("x-vercel-ip-postal-code") ?? null,
|
|
29
|
+
timezone: null
|
|
27
30
|
};
|
|
28
31
|
}
|
|
29
32
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/geolocation.ts"],"sourcesContent":["import type { Context } from 'hono';\n\nexport type Geolocation = {\n ip
|
|
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,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,gBAAg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