Skip to content
Open
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,16 @@ The backend includes abuse-oriented security instrumentation middleware.
- `security.failed_login_attempt`
- `security.rate_limit_triggered`
- `security.suspicious_pattern`
- Rate-limit logs include the limiter profile, request method, request path, threshold, and window without logging raw API keys or user identifiers.

### Thresholds (env-configurable)

| Env var | Default | Meaning |
|---|---|---|
| `ANALYTICS_RATE_LIMIT_WINDOW_MS` | `900000` | Analytics read rate-limit window |
| `ANALYTICS_RATE_LIMIT_MAX` | `120` | Max analytics requests per client key or IP in the analytics window |
| `MUTATION_RATE_LIMIT_WINDOW_MS` | `900000` | Mutation endpoint rate-limit window for `POST`, `PUT`, `PATCH`, `DELETE` |
| `MUTATION_RATE_LIMIT_MAX` | `40` | Max mutation requests per client key or IP in the mutation window |
| `SECURITY_RATE_LIMIT_WINDOW_MS` | `60000` | Rate-limit lookback window |
| `SECURITY_RATE_LIMIT_MAX_REQUESTS` | `120` | Max requests per IP in rate-limit window |
| `SECURITY_SUSPICIOUS_WINDOW_MS` | `300000` | Lookback window for suspicious pattern checks |
Expand Down
Binary file modified data/disciplr.db
Binary file not shown.
Binary file removed data/disciplr.db-shm
Binary file not shown.
Binary file removed data/disciplr.db-wal
Binary file not shown.
70 changes: 35 additions & 35 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 @@ -8,8 +8,8 @@
"build": "tsc",
"start": "node dist/index.js",
"lint": "eslint src --ext .ts",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.config.ts",
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.config.ts --watch",
"test:api-keys": "tsx --test src/routes/apiKeys.test.ts",
"test:vaults": "tsx --test src/routes/vaults.test.ts",
"migrate:make": "knex migrate:make --knexfile knexfile.cjs --migrations-directory db/migrations --extension cjs",
Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { createJobsRouter } from './routes/jobs.js'
import { BackgroundJobSystem } from './jobs/system.js'
import { authRouter } from './routes/auth.js'
import { analyticsRouter } from './routes/analytics.js'
import { healthRateLimiter, vaultsRateLimiter } from './middleware/rateLimiter.js'
import {
analyticsRateLimiter,
healthRateLimiter,
mutationRateLimiter,
vaultsRateLimiter,
} from './middleware/rateLimiter.js'
import { createExportRouter } from './routes/exports.js'
import { transactionsRouter } from './routes/transactions.js'
import { privacyRouter } from './routes/privacy.js'
Expand Down Expand Up @@ -37,13 +42,14 @@ app.use(securityMetricsMiddleware)
app.use(securityRateLimitMiddleware)

app.use('/api/health', healthRateLimiter, createHealthRouter(jobSystem))
app.use('/api', mutationRateLimiter)
app.use('/api/jobs', createJobsRouter(jobSystem))
app.use('/api/vaults', vaultsRateLimiter, vaultsRouter)
app.use('/api/vaults/:vaultId/milestones', milestonesRouter)
app.use('/api/auth', authRouter)
app.use('/api/exports', createExportRouter([]))
app.use('/api/transactions', transactionsRouter)
app.use('/api/analytics', analyticsRouter)
app.use('/api/analytics', analyticsRateLimiter, analyticsRouter)
app.use('/api/privacy', privacyRouter)
app.use('/api/organizations', orgVaultsRouter)
app.use('/api/organizations', orgAnalyticsRouter)
Expand Down
Loading