Skip to content

Commit

Permalink
chore(examples): Reorganize examples for clarity and decoupling from …
Browse files Browse the repository at this point in the history
…Next.js version (#2017)

This reorganizes our examples so they don't mention Next.js 14 unless they need to be locked to that version. It also updates Next.js to v15 where possible.

Since I needed to update the dependabot, ci, and merge queue configs, I also took the opportunity to update `-rl` to `-rate-limit` throughout for clarity.
  • Loading branch information
blaine-arcjet authored Oct 23, 2024
1 parent 1704da8 commit 8568bf2
Show file tree
Hide file tree
Showing 350 changed files with 26,515 additions and 20,677 deletions.
242 changes: 154 additions & 88 deletions .github/dependabot.yml

Large diffs are not rendered by default.

116 changes: 59 additions & 57 deletions .github/workflows/reusable-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ jobs:
working-directory: examples/nestjs-launchdarkly
run: npm run build

nextjs-14-app-dir-rl:
name: Next.js 14 + App Router + Rate Limit
nextjs-14-nextauth-4:
name: Next.js 14 + NextAuth 4
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# Environment security
- name: Harden Runner
Expand Down Expand Up @@ -198,15 +200,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-app-dir-rl
working-directory: examples/nextjs-14-nextauth-4
run: npm ci

- name: Build
working-directory: examples/nextjs-14-app-dir-rl
working-directory: examples/nextjs-14-nextauth-4
run: npm run build

nextjs-14-app-dir-validate-email:
name: Next.js 14 + App Router + Validate Email
nextjs-app-dir-rate-limit:
name: Next.js + App Router + Rate Limit
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -240,15 +242,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-app-dir-validate-email
working-directory: examples/nextjs-app-dir-rate-limit
run: npm ci

- name: Build
working-directory: examples/nextjs-14-app-dir-validate-email
working-directory: examples/nextjs-app-dir-rate-limit
run: npm run build

nextjs-14-authjs-5:
name: Next.js 14 + Auth.js 5
nextjs-app-dir-validate-email:
name: Next.js + App Router + Validate Email
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -282,17 +284,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-authjs-5
working-directory: examples/nextjs-app-dir-validate-email
run: npm ci

- name: Build
working-directory: examples/nextjs-14-authjs-5
env:
AUTH_SECRET: TEST_SECRET
working-directory: examples/nextjs-app-dir-validate-email
run: npm run build

nextjs-14-bot-categories:
name: Next.js 14 + Bot categories
nextjs-authjs-5:
name: Next.js + Auth.js 5
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -326,15 +326,17 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-bot-categories
working-directory: examples/nextjs-authjs-5
run: npm ci

- name: Build
working-directory: examples/nextjs-14-bot-categories
working-directory: examples/nextjs-authjs-5
env:
AUTH_SECRET: TEST_SECRET
run: npm run build

nextjs-14-clerk-rl:
name: Next.js 14 + Clerk + Rate Limit
nextjs-bot-categories:
name: Next.js + Bot categories
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -368,15 +370,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-clerk-rl
working-directory: examples/nextjs-bot-categories
run: npm ci

- name: Build
working-directory: examples/nextjs-14-clerk-rl
working-directory: examples/nextjs-bot-categories
run: npm run build

nextjs-14-clerk-shield:
name: Next.js 14 + Clerk + Shield
nextjs-clerk-rate-limit:
name: Next.js + Clerk + Rate Limit
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -410,15 +412,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-clerk-shield
working-directory: examples/nextjs-clerk-rate-limit
run: npm ci

- name: Build
working-directory: examples/nextjs-14-clerk-shield
working-directory: examples/nextjs-clerk-rate-limit
run: npm run build

nextjs-14-decorate:
name: Next.js 14 + Decorate
nextjs-clerk-shield:
name: Next.js + Clerk + Shield
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -452,15 +454,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-decorate
working-directory: examples/nextjs-clerk-shield
run: npm ci

- name: Build
working-directory: examples/nextjs-14-decorate
working-directory: examples/nextjs-clerk-shield
run: npm run build

nextjs-14-ip-details:
name: Next.js 14 + IP Details
nextjs-decorate:
name: Next.js + Decorate
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -494,15 +496,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-ip-details
working-directory: examples/nextjs-decorate
run: npm ci

- name: Build
working-directory: examples/nextjs-14-ip-details
working-directory: examples/nextjs-decorate
run: npm run build

nextjs-14-nextauth-4:
name: Next.js 14 + NextAuth 4
nextjs-ip-details:
name: Next.js + IP Details
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -536,15 +538,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-nextauth-4
working-directory: examples/nextjs-ip-details
run: npm ci

- name: Build
working-directory: examples/nextjs-14-nextauth-4
working-directory: examples/nextjs-ip-details
run: npm run build

nextjs-14-openai:
name: Next.js 14 + OpenAI
nextjs-openai:
name: Next.js + OpenAI
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -578,15 +580,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-openai
working-directory: examples/nextjs-openai
run: npm ci

- name: Build
working-directory: examples/nextjs-14-openai
working-directory: examples/nextjs-openai
run: npm run build

nextjs-14-pages-wrap:
name: Next.js 14 + Page Router + withArcjet
nextjs-pages-wrap:
name: Next.js + Page Router + withArcjet
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -620,15 +622,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-pages-wrap
working-directory: examples/nextjs-pages-wrap
run: npm ci

- name: Build
working-directory: examples/nextjs-14-pages-wrap
working-directory: examples/nextjs-pages-wrap
run: npm run build

nextjs-14-permit:
name: Next.js 14 + Permit
nextjs-permit:
name: Next.js + Permit
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -662,15 +664,15 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-permit
working-directory: examples/nextjs-permit
run: npm ci

- name: Build
working-directory: examples/nextjs-14-permit
working-directory: examples/nextjs-permit
run: npm run build

nextjs-14-sensitive-info:
name: Next.js 14 + Sensitive Info
nextjs-sensitive-info:
name: Next.js + Sensitive Info
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -704,11 +706,11 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nextjs-14-sensitive-info
working-directory: examples/nextjs-sensitive-info
run: npm ci

- name: Build
working-directory: examples/nextjs-14-sensitive-info
working-directory: examples/nextjs-sensitive-info
run: npm run build

nextjs-server-actions:
Expand Down Expand Up @@ -753,7 +755,7 @@ jobs:
working-directory: examples/nextjs-server-actions
run: npm run build

nodejs-hono-rl:
nodejs-hono-rate-limit:
name: Node.js + Hono + Rate Limit
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -786,11 +788,11 @@ jobs:
run: npm ci

- name: Install example dependencies
working-directory: examples/nodejs-hono-rl
working-directory: examples/nodejs-hono-rate-limit
run: npm ci

- name: Build
working-directory: examples/nodejs-hono-rl
working-directory: examples/nodejs-hono-rate-limit
run: npm run build

remix-express:
Expand Down
25 changes: 18 additions & 7 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,24 @@ merge:
- Trunk Check
- "Run tests / Run tests (OS: ubuntu-latest, Node: 18)"
- "Run tests / Run tests (OS: ubuntu-latest, Node: 20)"
- Build examples / Next.js 14 + App Router + Rate Limit
- Build examples / Next.js 14 + App Router + Validate Email
- Build examples / Next.js 14 + Clerk + Rate Limit
- Build examples / Next.js 14 + Clerk + Shield
- Build examples / Next.js 14 + Decorate
- Build examples / NestJS
- Build examples / NestJS + Fastify
- Build examples / NestJS + GraphQL
- Build examples / NestJS + LaunchDarkly
- Build examples / Next.js 14 + NextAuth 4
- Build examples / Next.js 14 + OpenAI
- Build examples / Next.js 14 + Page Router + withArcjet
- Build examples / Next.js + App Router + Rate Limit
- Build examples / Next.js + App Router + Validate Email
- Build examples / Next.js + Auth.js 5
- Build examples / Next.js + Bot categories
- Build examples / Next.js + Clerk + Rate Limit
- Build examples / Next.js + Clerk + Shield
- Build examples / Next.js + Decorate
- Build examples / Next.js + IP Details
- Build examples / Next.js + OpenAI
- Build examples / Next.js + Page Router + withArcjet
- Build examples / Next.js + Permit
- Build examples / Next.js + Sensitive Info
- Build examples / Next.js + Server Actions
- Build examples / Node.js + Hono + Rate Limit
- Build examples / Remix + Express
- Build examples / SvelteKit
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ for JS.

## Examples

- [Next.js rate limits](./examples/nextjs-14-app-dir-rl)
- [Next.js email validation](./examples/nextjs-14-app-dir-validate-email)
- [Bun rate limits](./examples/bun-rl)
- [Next.js rate limits](./examples/nextjs-app-dir-rate-limit)
- [Next.js email validation](./examples/nextjs-app-dir-validate-email)
- [Bun rate limits](./examples/bun-rate-limit)
- [Protect NextAuth login routes](./examples/nextjs-14-nextauth-4)
- [OpenAI chatbot protection](./examples/nextjs-14-openai)
- [Express.js rate limits](./examples/nodejs-express-rl)
- [OpenAI chatbot protection](./examples/nextjs-openai)
- [Express.js rate limits](./examples/nodejs-express-rate-limit)
- [SvelteKit](./examples/sveltekit)
- ... [more examples](./examples)

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This example shows how to use Arcjet with a Bun.sh
2. Enter this directory and install the example's dependencies.

```bash
cd examples/bun-hono-rl
cd examples/bun-hono-rate-limit
bun install
```

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "bun-hono-rl",
"name": "bun-hono-rate-limit",
"private": true,
"module": "index.ts",
"type": "module",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This example shows how to use Arcjet with a
2. Enter this directory and install the example's dependencies.

```bash
cd examples/bun-rl
cd examples/bun-rate-limit
bun install
```

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "bun-rl",
"name": "bun-rate-limit",
"private": true,
"module": "index.ts",
"type": "module",
Expand Down
File renamed without changes.
Loading

0 comments on commit 8568bf2

Please sign in to comment.