mirror of
https://github.com/hanzoai/chat.git
synced 2026-09-30 20:51:17 +00:00
Forks the internal @librechat/api workspace package (packages/api) to @hanzochat/api, matching the app package @hanzochat/chat. De-LibreChats the package name and puts its build under our control. Fixes the live prod bug where the deployed chat image shipped a stale @librechat/api/dist missing the exported handleError(), breaking every error path with "handleError is not a function" and killing the SSE stream. A clean build of @hanzochat/api produces dist/index.js that exports handleError (verified: exports.handleError = handleError). - packages/api/package.json: name @librechat/api -> @hanzochat/api - 254 source/config/doc/lockfile sites: @librechat/api -> @hanzochat/api (api/, packages/, config/, turbo.json, pnpm-lock.yaml, bun.lock, package-lock.json, LLM.md) - @librechat/api-client (distinct MCP client id string) left untouched - other @librechat/* packages (client, data-schemas, data-provider) left as-is per scope pnpm install (regenerated lockfile) + build:api green; dist exports handleError. api/data-schemas/client packages build; full build:packages and api test:ci are blocked by a PRE-EXISTING, unrelated upstream break in librechat-data-provider (config.spec.ts / cloudfront-config.spec.ts reference exports that src/config.ts no longer has) -- out of scope here.
18 lines
584 B
JavaScript
18 lines
584 B
JavaScript
const rateLimit = require('express-rate-limit');
|
|
const { limiterCache } = require('@hanzochat/api');
|
|
|
|
const PROMPT_USAGE_WINDOW_MS = 60 * 1000; // 1 minute
|
|
const PROMPT_USAGE_MAX = 30; // 30 usage increments per user per minute
|
|
|
|
const promptUsageLimiter = rateLimit({
|
|
windowMs: PROMPT_USAGE_WINDOW_MS,
|
|
max: PROMPT_USAGE_MAX,
|
|
handler: (_req, res) => {
|
|
res.status(429).json({ message: 'Too many prompt usage requests. Try again later' });
|
|
},
|
|
keyGenerator: (req) => req.user?.id,
|
|
store: limiterCache('prompt_usage_limiter'),
|
|
});
|
|
|
|
module.exports = { promptUsageLimiter };
|