Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Rename AJ_KEY to ARCJET_KEY & switch to next.js app dir example #201

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions arcjet-next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,27 @@ npm install -S @arcjet/next

```ts
import arcjet from "@arcjet/next";
import { NextApiRequest, NextApiResponse } from "next";
import { NextResponse } from "next/server";

const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY,
key: process.env.ARCJET_KEY,
rules: [],
});

export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
export async function GET(req: Request) {
const decision = await aj.protect(req);

if (decision.isDenied()) {
return res
.status(403)
.json({ error: "Forbidden", reason: decision.reason });
return NextResponse.json(
{ error: "Too Many Requests", reason: decision.reason },
{ status: 429 },
);
}

res.status(200).json({ name: "Hello world" });
return NextResponse.json({ message: "Hello world" });
}
```

Expand Down
2 changes: 1 addition & 1 deletion arcjet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://www.npmjs.com/package/dotenv
key: process.env.AJ_KEY,
key: process.env.ARCJET_KEY,
rules: [],
client: createRemoteClient({
transport: createConnectTransport({
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-13-pages-wrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Route](https://nextjs.org/docs/pages/building-your-application/routing/api-route
3. Add your Arcjet key to `.env.local`

```env
AJ_KEY=
ARCJET_KEY=
```

4. Start the dev server.
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-13-pages-wrap/pages/api/arcjet-edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [
fixedWindow({
mode: "LIVE",
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-13-pages-wrap/pages/api/arcjet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [
fixedWindow({
mode: "LIVE",
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-14-app-dir-rl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ handler](https://nextjs.org/docs/app/building-your-application/routing/route-han
3. Add your Arcjet key to `.env.local`

```env
AJ_KEY=
ARCJET_KEY=
```

4. Start the dev server.
Expand Down
2 changes: 1 addition & 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 @@ -5,7 +5,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [
fixedWindow({
mode: "LIVE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [
validateEmail({
mode: "LIVE",
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-14-app-dir-rl/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [],
});

Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-14-app-dir-validate-email/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ handler](https://nextjs.org/docs/app/building-your-application/routing/route-han
3. Add your Arcjet key to `.env.local`

```env
AJ_KEY=
ARCJET_KEY=
```

4. Start the dev server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [
validateEmail({
mode: "LIVE",
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-14-openai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ uses the OpenAI chat API.
3. Add your Arcjet & OpenAI keys to `.env.local`

```env
AJ_KEY=
ARCJET_KEY=
OPENAI_API_KEY=
```

Expand Down
4 changes: 2 additions & 2 deletions examples/nextjs-14-openai/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [
tokenBucket({
mode: "LIVE",
Expand Down Expand Up @@ -70,4 +70,4 @@ export async function POST(req: Request) {
const stream = OpenAIStream(response);
// Respond with the stream
return new StreamingTextResponse(stream);
}
}
2 changes: 1 addition & 1 deletion examples/nextjs-14-pages-wrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Route](https://nextjs.org/docs/pages/building-your-application/routing/api-route
3. Add your Arcjet key to `.env.local`

```env
AJ_KEY=
ARCJET_KEY=
```

4. Start the dev server.
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-14-pages-wrap/pages/api/arcjet-edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [
fixedWindow({
mode: "LIVE",
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-14-pages-wrap/pages/api/arcjet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const aj = arcjet({
// Get your site key from https://app.arcjet.com
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
key: process.env.AJ_KEY!,
key: process.env.ARCJET_KEY!,
rules: [
fixedWindow({
mode: "LIVE",
Expand Down
Loading