Skip to content

Commit 4cbd844

Browse files
refactor(ip): rename identifiers to match other casing (#4723)
When working on the fastify integration, i used `@arcjet/ip`. I noticed that I needed the `Cidr` type, which is a return value of `parseProxy` from there. So I expose it here. I also noticed that there are 2 functions, `parseProxy` as a named export and `findIp` as the default export. I expose the latter as a named export too, and deprecate the default symbol. Internally, the casing of abbreviations was more capital heavy, and not always consistent (`parseCIDR` and `isIPv4Cidr`). Especially around symbols such as `isIPv4Cidr` (previous casing), I find it hard to come up with good arguments why that `P` is uppercase but `v` lowercase. I like using capitals only for word boundaries: `parseCidr`, `isIpv4Cidr`, `Cidr`. So, before exposing values, I changed their internal names. See GH-4478 for more on that.
1 parent 0a638ae commit 4cbd844

File tree

9 files changed

+162
-166
lines changed

9 files changed

+162
-166
lines changed

arcjet-astro/internal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
Arcjet,
1010
CharacteristicProps,
1111
} from "arcjet";
12-
import findIP, { parseProxy } from "@arcjet/ip";
12+
import findIp, { parseProxy } from "@arcjet/ip";
1313
import { ArcjetHeaders } from "@arcjet/headers";
1414
import { baseUrl, isDevelopment, logLevel, platform } from "@arcjet/env";
1515
import { Logger } from "@arcjet/logger";
@@ -227,7 +227,7 @@ export function createArcjetClient<
227227
const headers = new ArcjetHeaders(request.headers);
228228

229229
const url = new URL(request.url);
230-
let ip = findIP(
230+
let ip = findIp(
231231
{
232232
ip: clientAddress,
233233
headers,

arcjet-bun/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
Arcjet,
1111
CharacteristicProps,
1212
} from "arcjet";
13-
import findIP, { parseProxy } from "@arcjet/ip";
13+
import findIp, { parseProxy } from "@arcjet/ip";
1414
import { ArcjetHeaders } from "@arcjet/headers";
1515
import type { Server } from "bun";
1616
import { env } from "bun";
@@ -223,7 +223,7 @@ export default function arcjet<
223223
const headers = new ArcjetHeaders(request.headers);
224224

225225
const url = new URL(request.url);
226-
let ip = findIP(
226+
let ip = findIp(
227227
{
228228
// This attempts to lookup the IP in the `ipCache`. This is primarily a
229229
// workaround to the API design in Bun that requires access to the

arcjet-deno/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
Arcjet,
1111
CharacteristicProps,
1212
} from "arcjet";
13-
import findIP, { parseProxy } from "@arcjet/ip";
13+
import findIp, { parseProxy } from "@arcjet/ip";
1414
import { ArcjetHeaders } from "@arcjet/headers";
1515
import { baseUrl, isDevelopment, logLevel, platform } from "@arcjet/env";
1616
import { Logger } from "@arcjet/logger";
@@ -225,7 +225,7 @@ export default function arcjet<
225225
const headers = new ArcjetHeaders(request.headers);
226226

227227
const url = new URL(request.url);
228-
let ip = findIP(
228+
let ip = findIp(
229229
{
230230
// This attempts to lookup the IP in the `ipCache`. This is primarily a
231231
// workaround to the API design in Deno that requires access to the

arcjet-nest/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
Arcjet,
1414
CharacteristicProps,
1515
} from "arcjet";
16-
import findIP, { parseProxy } from "@arcjet/ip";
16+
import findIp, { parseProxy } from "@arcjet/ip";
1717
import { ArcjetHeaders } from "@arcjet/headers";
1818
import { baseUrl, isDevelopment, logLevel, platform } from "@arcjet/env";
1919
import { Logger } from "@arcjet/logger";
@@ -242,7 +242,7 @@ function arcjet<
242242
// We construct an ArcjetHeaders to normalize over Headers
243243
const headers = new ArcjetHeaders(request.headers);
244244

245-
let ip = findIP(
245+
let ip = findIp(
246246
{
247247
ip: request.ip,
248248
socket: request.socket,

arcjet-next/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818
Arcjet,
1919
CharacteristicProps,
2020
} from "arcjet";
21-
import findIP, { parseProxy } from "@arcjet/ip";
21+
import findIp, { parseProxy } from "@arcjet/ip";
2222
import { ArcjetHeaders } from "@arcjet/headers";
2323
import { baseUrl, isDevelopment, logLevel, platform } from "@arcjet/env";
2424
import { Logger } from "@arcjet/logger";
@@ -436,7 +436,7 @@ export default function arcjet<
436436
// We construct an ArcjetHeaders to normalize over Headers
437437
const headers = new ArcjetHeaders(request.headers);
438438

439-
let ip = findIP(
439+
let ip = findIp(
440440
{
441441
ip: request.ip,
442442
socket: request.socket,

arcjet-node/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
Arcjet,
1010
CharacteristicProps,
1111
} from "arcjet";
12-
import findIP, { parseProxy } from "@arcjet/ip";
12+
import findIp, { parseProxy } from "@arcjet/ip";
1313
import { ArcjetHeaders } from "@arcjet/headers";
1414
import type { Env } from "@arcjet/env";
1515
import { baseUrl, isDevelopment, logLevel, platform } from "@arcjet/env";
@@ -265,7 +265,7 @@ export default function arcjet<
265265
// We construct an ArcjetHeaders to normalize over Headers
266266
const headers = new ArcjetHeaders(request.headers);
267267

268-
let ip = findIP(
268+
let ip = findIp(
269269
{
270270
socket: request.socket,
271271
headers,

arcjet-remix/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
Arcjet,
1010
CharacteristicProps,
1111
} from "arcjet";
12-
import findIP, { parseProxy } from "@arcjet/ip";
12+
import findIp, { parseProxy } from "@arcjet/ip";
1313
import { ArcjetHeaders } from "@arcjet/headers";
1414
import { baseUrl, isDevelopment, logLevel, platform } from "@arcjet/env";
1515
import { Logger } from "@arcjet/logger";
@@ -202,7 +202,7 @@ export default function arcjet<
202202
const headers = new ArcjetHeaders(request.headers);
203203

204204
const url = new URL(request.url);
205-
let ip = findIP(
205+
let ip = findIp(
206206
{
207207
// The `getLoadContext` API will attach the `ip` to the context
208208
ip: context?.ip,

arcjet-sveltekit/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
Arcjet,
1010
CharacteristicProps,
1111
} from "arcjet";
12-
import findIP, { parseProxy } from "@arcjet/ip";
12+
import findIp, { parseProxy } from "@arcjet/ip";
1313
import { ArcjetHeaders } from "@arcjet/headers";
1414
import { baseUrl, isDevelopment, logLevel, platform } from "@arcjet/env";
1515
import { Logger } from "@arcjet/logger";
@@ -218,7 +218,7 @@ export default function arcjet<
218218
// We construct an ArcjetHeaders to normalize over Headers
219219
const headers = new ArcjetHeaders(event.request.headers);
220220

221-
let ip = findIP(
221+
let ip = findIp(
222222
{
223223
ip: event.getClientAddress(),
224224
headers,

0 commit comments

Comments
 (0)