Skip to content

Commit

Permalink
feat: NestJS docs (bot protection, rate limiting, reference) (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmytton authored Nov 29, 2024
1 parent cc1c06e commit 41e1d6c
Show file tree
Hide file tree
Showing 145 changed files with 2,590 additions and 497 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@arcjet/deno": "1.0.0-alpha.32",
"@arcjet/env": "1.0.0-alpha.32",
"@arcjet/eslint-config": "1.0.0-alpha.32",
"@arcjet/headers": "^1.0.0-alpha.32",
"@arcjet/nest": "1.0.0-alpha.32",
"@arcjet/headers": "1.0.0-alpha.32",
"@arcjet/nest": "^1.0.0-alpha.32",
"@arcjet/next": "1.0.0-alpha.32",
"@arcjet/node": "1.0.0-alpha.32",
"@arcjet/protocol": "1.0.0-alpha.32",
Expand Down
4 changes: 4 additions & 0 deletions src/components/SDKVersionNestjs.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<picture class="badge">
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/arcjet?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/arcjet?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
20 changes: 16 additions & 4 deletions src/content/docs/bot-protection/quick-start.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
title: "Bot protection quick start"
description: "Quick start guide for adding Arcjet bot protection to your Next.js, Node.js, Bun, Remix, or SvelteKit app."
description: "Quick start guide for adding Arcjet bot protection to your Next.js, NestJS, Node.js, Bun, Remix, or SvelteKit app."
frameworks:
- bun
- deno
- nest-js
- next-js
- node-js
- remix
Expand All @@ -23,7 +24,7 @@ ajToc:
framework: ["bun", "node-js"]
- text: 4. Start app
anchor: "4-start-app"
framework: ["next-js", "remix", "sveltekit"]
framework: ["nest-js", "next-js", "remix", "sveltekit"]
- text: 5. Choose bots to allow or deny
anchor: "5-choose-bots-to-allow-or-deny"
- text: "FAQs"
Expand Down Expand Up @@ -51,6 +52,11 @@ import DenoStep2 from "@/snippets/bot-protection/quick-start/deno/Step2.mdx";
import DenoStep3 from "@/snippets/bot-protection/quick-start/deno/Step3.mdx";
import DenoStep4 from "@/snippets/bot-protection/quick-start/deno/Step4.mdx";

import NestJsStep1 from "@/snippets/bot-protection/quick-start/nestjs/Step1.mdx";
import NestJsStep2 from "@/snippets/bot-protection/quick-start/nestjs/Step2.mdx";
import NestJsStep3 from "@/snippets/bot-protection/quick-start/nestjs/Step3.mdx";
import NestJsStep4 from "@/snippets/bot-protection/quick-start/nestjs/Step4.mdx";

import NextJsStep1 from "@/snippets/bot-protection/quick-start/nextjs/Step1.mdx";
import NextJsStep2 from "@/snippets/bot-protection/quick-start/nextjs/Step2.mdx";
import NextJsStep3 from "@/snippets/bot-protection/quick-start/nextjs/Step3.mdx";
Expand Down Expand Up @@ -87,6 +93,7 @@ In your project root, run the following command to install the SDK:
<SlotByFramework client:load>
<BunStep1 slot="bun" />
<DenoStep1 slot="deno" />
<NestJsStep1 slot="nest-js" />
<NextJsStep1 slot="next-js" />
<NodeJsStep1 slot="node-js" />
<RemixStep1 slot="remix" />
Expand All @@ -101,6 +108,7 @@ instructions to add a site and get a key.
<SlotByFramework client:load>
<BunStep2 slot="bun" />
<DenoStep2 slot="deno" />
<NestJsStep2 slot="nest-js" />
<NextJsStep2 slot="next-js" />
<NodeJsStep2 slot="node-js" />
<RemixStep2 slot="remix" />
Expand All @@ -112,6 +120,7 @@ instructions to add a site and get a key.
<SlotByFramework client:load>
<BunStep3 slot="bun" />
<DenoStep3 slot="deno" />
<NestJsStep3 slot="nest-js" />
<NextJsStep3 slot="next-js" />
<NodeJsStep3 slot="node-js" />
<RemixStep3 slot="remix" />
Expand All @@ -121,17 +130,20 @@ instructions to add a site and get a key.
<SlotByFramework client:load>
<BunStep4 slot="bun" />
<DenoStep4 slot="deno" />
<NestJsStep4 slot="nest-js" />
<NextJsStep4 slot="next-js" />
<NodeJsStep4 slot="node-js" />
<RemixStep4 slot="remix" />
<SvelteKitStep4 slot="sveltekit" />
</SlotByFramework>

The requests will also show in the [Arcjet dashboard](https://app.arcjet.com).

### 5. Choose bots to allow or deny

Arcjet maintains a list of known bots so you can choose to either only [allow
specific bots](/bot-protection/reference) or only [deny specific
bots](/bot-protection/reference).
specific bots](/bot-protection/reference#allowing-specific-bots) or only [deny
specific bots](/bot-protection/reference#denying-specific-bots).

Check out our [full list of bots](https://arcjet.com/bot-list).

Expand Down
70 changes: 51 additions & 19 deletions src/content/docs/bot-protection/reference.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
title: "Bot protection reference"
description: "Reference guide for adding Arcjet bot protection to your Next.js, Node.js, Bun, Remix, or SvelteKit app."
description: "Reference guide for adding Arcjet bot protection to your Next.js, NestJS, Node.js, Bun, Remix, or SvelteKit app."
frameworks:
- bun
- deno
- nest-js
- next-js
- node-js
- remix
Expand All @@ -16,6 +17,16 @@ ajToc:
anchor: "allowing-specific-bots"
- text: "Denying specific bots"
anchor: "denying-specific-bots"
- text: "Guards and routes"
anchor: "guards-and-routes"
framework: ["nest-js"]
children:
- text: "Global guard"
anchor: "global-guard"
- text: "Per route guard"
anchor: "per-route-guard"
- text: "Within route"
anchor: "within-route"
- text: "Per route vs middleware"
anchor: "per-route-vs-middleware"
framework: ["next-js"]
Expand Down Expand Up @@ -58,54 +69,63 @@ ajToc:
framework: ["next-js"]
---

import SlotByFramework from "@/components/SlotByFramework";
import Comments from "@/components/Comments.astro";
import SlotByFramework from "@/components/SlotByFramework";
import TextByFramework from "@/components/TextByFramework";

import BunAllowingBots from "@/snippets/bot-protection/reference/bun/AllowingBots.mdx";
import BunDenyingBots from "@/snippets/bot-protection/reference/bun/DenyingBots.mdx";
import BunDecisionLog from "@/snippets/bot-protection/reference/bun/DecisionLog.mdx";
import BunIdentifiedBots from "@/snippets/bot-protection/reference/bun/IdentifiedBots.mdx";
import BunDenyingBots from "@/snippets/bot-protection/reference/bun/DenyingBots.mdx";
import BunErrors from "@/snippets/bot-protection/reference/bun/Errors.mdx";
import BunFiltering from "@/snippets/bot-protection/reference/bun/Filtering.mdx";
import BunIdentifiedBots from "@/snippets/bot-protection/reference/bun/IdentifiedBots.mdx";

import DenoAllowingBots from "@/snippets/bot-protection/reference/deno/AllowingBots.mdx";
import DenoDenyingBots from "@/snippets/bot-protection/reference/deno/DenyingBots.mdx";
import DenoDecisionLog from "@/snippets/bot-protection/reference/deno/DecisionLog.mdx";
import DenoIdentifiedBots from "@/snippets/bot-protection/reference/deno/IdentifiedBots.mdx";
import DenoDenyingBots from "@/snippets/bot-protection/reference/deno/DenyingBots.mdx";
import DenoErrors from "@/snippets/bot-protection/reference/deno/Errors.mdx";
import DenoFiltering from "@/snippets/bot-protection/reference/deno/Filtering.mdx";
import DenoIdentifiedBots from "@/snippets/bot-protection/reference/deno/IdentifiedBots.mdx";

import NestJsAllowingBots from "@/snippets/bot-protection/reference/nestjs/AllowingBots.mdx";
import NestJsDecisionLog from "@/snippets/bot-protection/reference/nestjs/DecisionLog.mdx";
import NestJsDecoratorRoutes from "@/snippets/bot-protection/reference/nestjs/DecoratorRoutes.mdx";
import NestJsDenyingBots from "@/snippets/bot-protection/reference/nestjs/DenyingBots.mdx";
import NestJsErrors from "@/snippets/bot-protection/reference/nestjs/Errors.mdx";
import NestJsFiltering from "@/snippets/bot-protection/reference/nestjs/Filtering.mdx";
import NestJsIdentifiedBots from "@/snippets/bot-protection/reference/nestjs/IdentifiedBots.mdx";

import NextJsAllowingBots from "@/snippets/bot-protection/reference/nextjs/AllowingBots.mdx";
import NextJsDenyingBots from "@/snippets/bot-protection/reference/nextjs/DenyingBots.mdx";
import NextJsPerRouteVsMiddleware from "@/snippets/bot-protection/reference/nextjs/PerRouteVsMiddleware.mdx";
import NextJsDecisionLog from "@/snippets/bot-protection/reference/nextjs/DecisionLog.mdx";
import NextJsIdentifiedBots from "@/snippets/bot-protection/reference/nextjs/IdentifiedBots.mdx";
import NextJsDenyingBots from "@/snippets/bot-protection/reference/nextjs/DenyingBots.mdx";
import NextJsErrors from "@/snippets/bot-protection/reference/nextjs/Errors.mdx";
import NextJsFiltering from "@/snippets/bot-protection/reference/nextjs/Filtering.mdx";
import NextJsExamples from "@/snippets/bot-protection/reference/nextjs/Examples.mdx";
import NextJsFiltering from "@/snippets/bot-protection/reference/nextjs/Filtering.mdx";
import NextJsIdentifiedBots from "@/snippets/bot-protection/reference/nextjs/IdentifiedBots.mdx";
import NextJsPerRouteVsMiddleware from "@/snippets/bot-protection/reference/nextjs/PerRouteVsMiddleware.mdx";

import NodeJsAllowingBots from "@/snippets/bot-protection/reference/nodejs/AllowingBots.mdx";
import NodeJsDenyingBots from "@/snippets/bot-protection/reference/nodejs/DenyingBots.mdx";
import NodeJsDecisionLog from "@/snippets/bot-protection/reference/nodejs/DecisionLog.mdx";
import NodeJsIdentifiedBots from "@/snippets/bot-protection/reference/nodejs/IdentifiedBots.mdx";
import NodeJsDenyingBots from "@/snippets/bot-protection/reference/nodejs/DenyingBots.mdx";
import NodeJsErrors from "@/snippets/bot-protection/reference/nodejs/Errors.mdx";
import NodeJsFiltering from "@/snippets/bot-protection/reference/nodejs/Filtering.mdx";
import NodeJsIdentifiedBots from "@/snippets/bot-protection/reference/nodejs/IdentifiedBots.mdx";

import RemixAllowingBots from "@/snippets/bot-protection/reference/remix/AllowingBots.mdx";
import RemixDenyingBots from "@/snippets/bot-protection/reference/remix/DenyingBots.mdx";
import RemixDecisionLog from "@/snippets/bot-protection/reference/remix/DecisionLog.mdx";
import RemixIdentifiedBots from "@/snippets/bot-protection/reference/remix/IdentifiedBots.mdx";
import RemixDenyingBots from "@/snippets/bot-protection/reference/remix/DenyingBots.mdx";
import RemixErrors from "@/snippets/bot-protection/reference/remix/Errors.mdx";
import RemixFiltering from "@/snippets/bot-protection/reference/remix/Filtering.mdx";
import RemixIdentifiedBots from "@/snippets/bot-protection/reference/remix/IdentifiedBots.mdx";
import RemixLoaderVsAction from "@/snippets/bot-protection/reference/remix/LoaderVsAction.mdx";

import SvelteKitAllowingBots from "@/snippets/bot-protection/reference/sveltekit/AllowingBots.mdx";
import SvelteKitDenyingBots from "@/snippets/bot-protection/reference/sveltekit/DenyingBots.mdx";
import SvelteKitPerRouteVsHooks from "@/snippets/bot-protection/reference/sveltekit/PerRouteVsHooks.mdx";
import SvelteKitDecisionLog from "@/snippets/bot-protection/reference/sveltekit/DecisionLog.mdx";
import SvelteKitIdentifiedBots from "@/snippets/bot-protection/reference/sveltekit/IdentifiedBots.mdx";
import SvelteKitDenyingBots from "@/snippets/bot-protection/reference/sveltekit/DenyingBots.mdx";
import SvelteKitErrors from "@/snippets/bot-protection/reference/sveltekit/Errors.mdx";
import SvelteKitFiltering from "@/snippets/bot-protection/reference/sveltekit/Filtering.mdx";
import SvelteKitIdentifiedBots from "@/snippets/bot-protection/reference/sveltekit/IdentifiedBots.mdx";
import SvelteKitPerRouteVsHooks from "@/snippets/bot-protection/reference/sveltekit/PerRouteVsHooks.mdx";

Arcjet bot detection allows you to manage traffic by automated clients and bots.

Expand Down Expand Up @@ -155,6 +175,7 @@ categories](/bot-protection/identifying-bots#bot-categories).
<SlotByFramework client:load>
<BunAllowingBots slot="bun" />
<DenoAllowingBots slot="deno" />
<NestJsAllowingBots slot="nest-js" />
<NextJsAllowingBots slot="next-js" />
<NodeJsAllowingBots slot="node-js" />
<RemixAllowingBots slot="remix" />
Expand All @@ -174,13 +195,15 @@ categories](/bot-protection/identifying-bots#bot-categories).
<SlotByFramework client:load>
<BunDenyingBots slot="bun" />
<DenoDenyingBots slot="deno" />
<NestJsDenyingBots slot="nest-js" />
<NextJsDenyingBots slot="next-js" />
<NodeJsDenyingBots slot="node-js" />
<RemixDenyingBots slot="remix" />
<SvelteKitDenyingBots slot="sveltekit" />
</SlotByFramework>

<SlotByFramework client:load>
<NestJsDecoratorRoutes slot="nest-js" />
<NextJsPerRouteVsMiddleware slot="next-js" />
<RemixLoaderVsAction slot="remix" />
<SvelteKitPerRouteVsHooks slot="sveltekit" />
Expand All @@ -195,6 +218,13 @@ Arcjet also provides a single `protect` function that is used to execute your
protection rules. This requires a `request` argument which is the request
context as passed to the request handler.

<TextByFramework framework="nest-js" client:load>
<br />
If you are using a global guard or per route guard then `protect` is called for
you behind the scenes. If you add Arcjet within a route then you call it
directly.

</TextByFramework>
This function returns a `Promise` that resolves to an
`ArcjetDecision` object. This contains the following properties:

Expand Down Expand Up @@ -224,11 +254,10 @@ for (const result of decision.results) {
}
```

This example will log the full result as well as the bot protection rule:

<SlotByFramework client:load>
<BunDecisionLog slot="bun" />
<DenoDecisionLog slot="deno" />
<NestJsDecisionLog slot="nest-js" />
<NextJsDecisionLog slot="next-js" />
<NodeJsDecisionLog slot="node-js" />
<RemixDecisionLog slot="remix" />
Expand All @@ -246,6 +275,7 @@ properties.
<SlotByFramework client:load>
<BunIdentifiedBots slot="bun" />
<DenoIdentifiedBots slot="deno" />
<NestJsIdentifiedBots slot="nest-js" />
<NextJsIdentifiedBots slot="next-js" />
<NodeJsIdentifiedBots slot="node-js" />
<RemixIdentifiedBots slot="remix" />
Expand Down Expand Up @@ -276,6 +306,7 @@ See [an example of how to do this](/bot-protection/concepts#user-agent-header).
<SlotByFramework client:load>
<BunErrors slot="bun" />
<DenoErrors slot="deno" />
<NestJsErrors slot="nest-js" />
<NextJsErrors slot="next-js" />
<NodeJsErrors slot="node-js" />
<RemixErrors slot="remix" />
Expand All @@ -291,6 +322,7 @@ their "advertising quality" bot.
<SlotByFramework client:load>
<BunFiltering slot="bun" />
<DenoFiltering slot="deno" />
<NestJsFiltering slot="nest-js" />
<NextJsFiltering slot="next-js" />
<NodeJsFiltering slot="node-js" />
<RemixFiltering slot="remix" />
Expand Down
2 changes: 2 additions & 0 deletions src/content/docs/email-validation/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ a deny decision.
<Step4SvelteKit slot="sveltekit" />
</SlotByFramework>

The requests will also show in the [Arcjet dashboard](https://app.arcjet.com).

## FAQs

<FAQs />
Expand Down
2 changes: 2 additions & 0 deletions src/content/docs/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ limit, and prevent bots from accessing your app.
<SvelteKitStep4 slot="sveltekit" />
</SlotByFramework>

The requests will also show in the [Arcjet dashboard](https://app.arcjet.com).

## What next?

<SlotByFramework client:load>
Expand Down
16 changes: 14 additions & 2 deletions src/content/docs/rate-limiting/quick-start.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
title: "Rate limiting"
description: "Quick start guide for adding Arcjet rate limiting to your Next.js, Node.js, Bun, Remix, or SvelteKit app."
description: "Quick start guide for adding Arcjet rate limiting to your Next.js, NestJS, Node.js, Bun, Remix, or SvelteKit app."
frameworks:
- bun
- nest-js
- next-js
- node-js
- remix
Expand All @@ -25,7 +26,7 @@ ajToc:
framework: ["bun", "node-js"]
- text: 4. Start app
anchor: "4-start-app"
framework: ["next-js", "remix", "sveltekit"]
framework: ["nest-js", "next-js", "remix", "sveltekit"]
- text: "FAQs"
anchor: "faqs"
- text: "What next?"
Expand All @@ -46,6 +47,11 @@ import BunStep2 from "@/snippets/rate-limiting/quick-start/bun/Step2.mdx";
import BunStep3 from "@/snippets/rate-limiting/quick-start/bun/Step3.mdx";
import BunStep4 from "@/snippets/rate-limiting/quick-start/bun/Step4.mdx";

import NestJsStep1 from "@/snippets/rate-limiting/quick-start/nestjs/Step1.mdx";
import NestJsStep2 from "@/snippets/rate-limiting/quick-start/nestjs/Step2.mdx";
import NestJsStep3 from "@/snippets/rate-limiting/quick-start/nestjs/Step3.mdx";
import NestJsStep4 from "@/snippets/rate-limiting/quick-start/nestjs/Step4.mdx";

import NextJsVideoQuickStart from "@/snippets/rate-limiting/quick-start/nextjs/VideoQuickStart.mdx";
import NextJsStep1 from "@/snippets/rate-limiting/quick-start/nextjs/Step1.mdx";
import NextJsStep2 from "@/snippets/rate-limiting/quick-start/nextjs/Step2.mdx";
Expand Down Expand Up @@ -86,6 +92,7 @@ In your project root, run the following command to install the SDK:

<SlotByFramework client:load>
<BunStep1 slot="bun" />
<NestJsStep1 slot="nest-js" />
<NextJsStep1 slot="next-js" />
<NodeJsStep1 slot="node-js" />
<RemixStep1 slot="remix" />
Expand All @@ -99,6 +106,7 @@ instructions to add a site and get a key.

<SlotByFramework client:load>
<BunStep2 slot="bun" />
<NestJsStep2 slot="nest-js" />
<NextJsStep2 slot="next-js" />
<NodeJsStep2 slot="node-js" />
<RemixStep2 slot="remix" />
Expand All @@ -114,6 +122,7 @@ configured with a maximum capacity of 10 tokens and refills by 5 tokens every

<SlotByFramework client:load>
<BunStep3 slot="bun" />
<NestJsStep3 slot="nest-js" />
<NextJsStep3 slot="next-js" />
<NodeJsStep3 slot="node-js" />
<RemixStep3 slot="remix" />
Expand All @@ -122,12 +131,15 @@ configured with a maximum capacity of 10 tokens and refills by 5 tokens every

<SlotByFramework client:load>
<BunStep4 slot="bun" />
<NestJsStep4 slot="nest-js" />
<NextJsStep4 slot="next-js" />
<NodeJsStep4 slot="node-js" />
<RemixStep4 slot="remix" />
<SvelteKitStep4 slot="sveltekit" />
</SlotByFramework>

The requests will also show in the [Arcjet dashboard](https://app.arcjet.com).

## FAQs

<FAQs />
Expand Down
Loading

0 comments on commit 41e1d6c

Please sign in to comment.