Skip to content

Commit

Permalink
fixup tests and next bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
blaine-arcjet committed Feb 2, 2024
1 parent f151a96 commit d2b55ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
14 changes: 11 additions & 3 deletions arcjet-next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import type { NextMiddlewareResult } from "next/dist/server/web/types.js";
import arcjet, {
ArcjetDecision,
ArcjetOptions,
Primitive,
Product,
ArcjetHeaders,
Runtime,
ArcjetRequest,
Expand All @@ -21,6 +19,8 @@ import arcjet, {
RemoteClientOptions,
defaultBaseUrl,
createRemoteClient,
ArcjetPrimitive,
ArcjetProduct,
} from "arcjet";
import findIP from "@arcjet/ip";

Expand Down Expand Up @@ -64,6 +64,14 @@ type PlainObject = {
[key: string]: unknown;
};

// Primitives and Products can be specified in a variety of ways and are
// externally grouped as `rules`
// See ExtraRules below for further explanation on why we define them like this.
type PrimitivesOrProduct<Props extends {} = {}> =
| ArcjetPrimitive<Props>
| ArcjetPrimitive<Props>[]
| ArcjetProduct<Props>;

/**
* Ensures redirects are followed to properly support the Next.js/Vercel Edge
* Runtime.
Expand Down Expand Up @@ -157,7 +165,7 @@ export interface ArcjetNext<Props extends PlainObject> {
* These can be overriden on a per-request basis by providing them to the
* `protect()` or `protectApi` methods.
*/
export default function arcjetNext<const Rules extends (Primitive | Product)[]>(
export default function arcjetNext<const Rules extends PrimitivesOrProduct[]>(
options: ArcjetOptions<Rules>,
): ArcjetNext<Simplify<ExtraProps<Rules>>> {
const client = options.client ?? createNextRemoteClient();
Expand Down
1 change: 0 additions & 1 deletion examples/nextjs-13-pages-wrap/pages/api/arcjet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const aj = arcjet({
//characteristics: ["ip.src"],
window: "1m",
max: 1,
timeout: "10m",
}),
],
});
Expand Down
1 change: 0 additions & 1 deletion examples/nextjs-14-app-dir-rl/app/api/arcjet/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const aj = arcjet({
characteristics: ["ip.src"],
window: "1h",
max: 1,
timeout: "10m",
}),
],
});
Expand Down

0 comments on commit d2b55ab

Please sign in to comment.