Skip to content

Commit 168a322

Browse files
committed
init
0 parents  commit 168a322

28 files changed

+4899
-0
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
REDIS_URL=xxx

.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
.env
31+
32+
# vercel
33+
.vercel
34+
35+
# typescript
36+
*.tsbuildinfo
37+
next-env.d.ts

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# nextjs-rate-limit
2+
3+
> Rate Limit your Next.js API Routes using `rate-limiter-flexible`. The Easy Way!
4+
5+
#### 1. Install dependencies
6+
7+
```bash
8+
pnpm install
9+
```
10+
11+
#### 2. Run dev server in one terminal
12+
13+
```bash
14+
pnpm dev
15+
```
16+
17+
#### 3. Run rate limit script on another terminal
18+
19+
```bash
20+
pnpm automate:ratelimit
21+
```
22+
23+
#### 4. Run download script
24+
25+
```bash
26+
pnpm automate:download
27+
```
28+
29+
#### 5. Read all Redis Keys & Values
30+
31+
```bash
32+
pnpm redis:getall
33+
```

declaration.d.ts

Whitespace-only changes.

next.config.mjs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import jiti from 'jiti'
2+
import { fileURLToPath } from 'node:url'
3+
4+
const filename = fileURLToPath(import.meta.url)
5+
const envPath = './src/app/lib/env'
6+
7+
jiti(filename)(envPath)
8+
9+
/** @type {import('next').NextConfig} */
10+
const nextConfig = {}
11+
12+
export default nextConfig

package.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "nextjs-rate-limit",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint",
10+
"clean": "rimraf .next",
11+
"knip": "knip",
12+
"automate:login": "tsx ./src/automate-rate-limit/login.ts",
13+
"automate:download": "tsx ./src/automate-rate-limit/download.ts",
14+
"redis:getall": "node --import tsx --env-file .env ./src/automate-rate-limit/get-all-keys.ts"
15+
},
16+
"dependencies": {
17+
"@fingerprintjs/fingerprintjs": "^4.2.2",
18+
"@t3-oss/env-nextjs": "^0.8.0",
19+
"consola": "^3.2.3",
20+
"ioredis": "^5.3.2",
21+
"next": "14.1.0",
22+
"public-ip": "^6.0.1",
23+
"rate-limiter-flexible": "^4.0.1",
24+
"react": "^18.2.0",
25+
"react-dom": "^18.2.0",
26+
"zod": "^3.22.4",
27+
"zustand": "^4.5.0"
28+
},
29+
"devDependencies": {
30+
"@types/node": "^20.11.16",
31+
"@types/react": "^18.2.55",
32+
"@types/react-dom": "^18.2.18",
33+
"autoprefixer": "^10.4.17",
34+
"eslint": "^8.56.0",
35+
"eslint-config-next": "14.1.0",
36+
"jiti": "^1.21.0",
37+
"knip": "^4.4.0",
38+
"postcss": "^8.4.34",
39+
"rimraf": "^5.0.5",
40+
"tailwindcss": "^3.4.1",
41+
"tsx": "^4.7.0",
42+
"typescript": "^5.3.3"
43+
}
44+
}

0 commit comments

Comments
 (0)