@shware/http 0.2.10 → 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.
- package/dist/hono/geolocation.cjs +19 -19
- package/dist/hono/geolocation.cjs.map +1 -1
- package/dist/hono/geolocation.d.cts +1 -4
- package/dist/hono/geolocation.d.ts +1 -4
- package/dist/hono/geolocation.mjs +18 -17
- package/dist/hono/geolocation.mjs.map +1 -1
- package/dist/hono/index.cjs +0 -2
- package/dist/hono/index.cjs.map +1 -1
- package/dist/hono/index.d.cts +1 -1
- package/dist/hono/index.d.ts +1 -1
- package/dist/hono/index.mjs +1 -2
- package/dist/hono/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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 */\
|
|
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,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|
|
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
|
|
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
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 */\
|
|
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":[]}
|
package/dist/hono/index.cjs
CHANGED
|
@@ -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
|
package/dist/hono/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation
|
|
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":[]}
|
package/dist/hono/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { zValidator } from './validator.cjs';
|
|
2
2
|
export { errorHandler } from './handler.cjs';
|
|
3
|
-
export { geolocation
|
|
3
|
+
export { geolocation } from './geolocation.cjs';
|
|
4
4
|
import 'hono/utils/headers';
|
|
5
5
|
import 'hono/types';
|
|
6
6
|
import 'hono';
|
package/dist/hono/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { zValidator } from './validator.js';
|
|
2
2
|
export { errorHandler } from './handler.js';
|
|
3
|
-
export { geolocation
|
|
3
|
+
export { geolocation } from './geolocation.js';
|
|
4
4
|
import 'hono/utils/headers';
|
|
5
5
|
import 'hono/types';
|
|
6
6
|
import 'hono';
|
package/dist/hono/index.mjs
CHANGED
|
@@ -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
|
|
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
|
package/dist/hono/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hono/index.ts"],"sourcesContent":["export { zValidator } from './validator';\nexport { errorHandler } from './handler';\nexport { geolocation
|
|
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":[]}
|