Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix: improved rate limiter

Carl-Gerhard Lindesvärd8e602234bb85
diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts
index 92f251351..176fa63d9 100644
--- a/apps/api/src/app.ts
+++ b/apps/api/src/app.ts
@@ -11,6 +11,7 @@ import {
validateSessionToken,
} from '@openpanel/auth';
import { generateId } from '@openpanel/common';
+import { getTrustedIpFromHeaders } from '@openpanel/common/server/get-client-ip';
import { type IServiceClientWithProject, runWithAlsSession } from '@openpanel/db';
import type { AppRouter } from '@openpanel/trpc';
import { appRouter, createContext } from '@openpanel/trpc';
@@ -175,16 +176,33 @@ export async function buildApp(
if (ctx.error.code === 'UNAUTHORIZED' && ctx.path === 'organization.list') {
return;
}
- ctx.req.log.error(
- {
- err: ctx.error,
- path: ctx.path,
- input: ctx.input,
- type: ctx.type,
- session: ctx.ctx?.session,
- },
- 'trpc error',
+
+ // The IP is resolved from trusted headers only (see
+ // `getTrustedIpFromHeaders`), so it is the address to hand to
+ // Cloudflare when an abuser needs blocking at the edge.
+ const { ip, header } = getTrustedIpFromHeaders(
+ ctx.req.headers,
+ ctx.req.socket?.remoteAddress,
);
+ const payload = {
+ err: ctx.error,
+ path: ctx.path,
+ input: ctx.input,
+ type: ctx.type,
+ session: ctx.ctx?.session,
+ ip,
+ ipHeader: header,
+ userAgent: ctx.req.headers['user-agent'],
+ };
+
+ // Being rate limited is the system working, not an error - logging it
+ // as one buried the real errors under 15k lines a day.
+ if (ctx.error.code === 'TOO_MANY_REQUESTS') {
+ ctx.req.log.warn(payload, 'trpc rate limited');
+ return;
+ }
+
+ ctx.req.log.error(payload, 'trpc error');
},
} satisfies FastifyTRPCPluginOptions<AppRouter>['trpcOptions'],
});
diff --git a/apps/api/src/routes/insights.router.test.ts b/apps/api/src/routes/insights.router.test.ts
index be2ea05f0..b031e0a22 100644
--- a/apps/api/src/routes/insights.router.test.ts
+++ b/apps/api/src/routes/insights.router.test.ts
@@ -29,8 +29,8 @@ vi.mock('@openpanel/common/server', async (importOriginal) => {
});
// Bypass Redis caching — no real ioredis connections in tests.
-// getRedisCache must return a truthy object so that @trpc-limiter/redis's
-// RateLimiterRedis constructor doesn't throw "storeClient is not set".
+// getRedisCache must return a truthy object; the rate limiter falls back to its
+// in-process counter when the fake client cannot serve a pipeline.
vi.mock('@openpanel/redis', async (importOriginal) => {
const actual = await importOriginal<typeof import('@openpanel/redis')>();
const fakeRedisClient = new Proxy(
diff --git a/apps/api/src/utils/rate-limiter.ts b/apps/api/src/utils/rate-limiter.ts
index be670090a..b30e96fb6 100644
--- a/apps/api/src/utils/rate-limiter.ts
+++ b/apps/api/src/utils/rate-limiter.ts
@@ -1,3 +1,4 @@
+import { getTrustedIpFromHeaders } from '@openpanel/common/server/get-client-ip';
import { getRedisCache } from '@openpanel/redis';
import type { FastifyInstance, FastifyRequest } from 'fastify';
@@ -31,15 +32,27 @@ export async function activateRateLimiter<T extends FastifyRequest>({
return key;
}
}
- return (req.headers['openpanel-client-id'] ||
- req.headers['x-real-ip'] ||
- req.headers['x-client-ip'] ||
- req.headers['x-forwarded-for']) as string;
+ // Only trusted headers - `x-client-ip` / `x-forwarded-for` are set by the
+ // caller, so keying on them hands out a fresh bucket per request.
+ return (
+ (req.headers['openpanel-client-id'] as string) ||
+ getTrustedIpFromHeaders(req.headers, req.socket?.remoteAddress).ip
+ );
},
- onExceeded: (req, reply) => {
+ onExceeded: (req) => {
+ const { ip, header } = getTrustedIpFromHeaders(
+ req.headers,
+ req.socket?.remoteAddress,
+ );
req.log.warn(
- { clientId: req.headers['openpanel-client-id'] },
- 'Rate limit exceeded',
+ {
+ clientId: req.headers['openpanel-client-id'],
+ ip,
+ ipHeader: header,
+ url: req.url,
+ userAgent: req.headers['user-agent'],
+ },
+ 'rate limit exceeded',
);
},
});
diff --git a/packages/common/server/get-client-ip.test.ts b/packages/common/server/get-client-ip.test.ts
new file mode 100644
index 000000000..4485de906
--- /dev/null
+++ b/packages/common/server/get-client-ip.test.ts
@@ -0,0 +1,53 @@
+import { describe, expect, it } from 'vitest';
+import {
+ getClientIpFromHeaders,
+ getTrustedIpFromHeaders,
+} from './get-client-ip';
+
+describe('getTrustedIpFromHeaders', () => {
+ it('prefers cf-connecting-ip over anything the caller can set', () => {
+ // Verified against production: Cloudflare overwrites cf-connecting-ip, but
+ // passes a forged x-forwarded-for / x-client-ip straight through.
+ const headers = {
+ 'x-client-ip': '9.9.9.9',
+ 'x-forwarded-for': '8.8.8.8',
+ 'cf-connecting-ip': '98.128.229.56',
+ };
+
+ expect(getTrustedIpFromHeaders(headers)).toEqual({
+ ip: '98.128.229.56',
+ header: 'cf-connecting-ip',
+ });
+
+ // The analytics resolver deliberately trusts the caller - that is the
+ // difference the two functions exist for.
+ expect(getClientIpFromHeaders(headers).ip).toBe('9.9.9.9');
+ });
+
+ it('never returns a client-forwarded header', () => {
+ expect(
+ getTrustedIpFromHeaders({
+ 'openpanel-client-ip': '9.9.9.9',
+ 'x-client-ip': '7.7.7.7',
+ 'true-client-ip': '6.6.6.6',
+ }).ip,
+ ).toBe('');
+ });
+
+ it('takes the last x-forwarded-for entry, the one the proxy appended', () => {
+ expect(
+ getTrustedIpFromHeaders({ 'x-forwarded-for': '8.8.8.8, 1.2.3.4' }),
+ ).toEqual({ ip: '1.2.3.4', header: 'x-forwarded-for' });
+ });
+
+ it('falls back to the socket address, private ranges included', () => {
+ expect(getTrustedIpFromHeaders({}, '127.0.0.1')).toEqual({
+ ip: '127.0.0.1',
+ header: 'socket',
+ });
+ });
+
+ it('returns nothing when there is neither a trusted header nor a socket', () => {
+ expect(getTrustedIpFromHeaders({})).toEqual({ ip: '', header: '' });
+ });
+});
diff --git a/packages/common/server/get-client-ip.ts b/packages/common/server/get-client-ip.ts
index b5edadc76..8bebbe60c 100644
--- a/packages/common/server/get-client-ip.ts
+++ b/packages/common/server/get-client-ip.ts
@@ -146,3 +146,76 @@ export function getClientIpFromHeaders(
return { ip: '', header: '' };
}
+
+/**
+ * Headers that may be trusted for *security* decisions (rate limiting,
+ * blocking, abuse tracking).
+ *
+ * `getClientIpFromHeaders` above deliberately prefers client-forwarded
+ * headers (`openpanel-client-ip`, `x-client-ip`, `x-forwarded-for`) because an
+ * SDK running on a customer's server forwards the end-user IP that way. That
+ * trust is correct for analytics attribution and fatal for rate limiting:
+ * anyone can send `x-client-ip: <random>` on every request and get an endless
+ * supply of fresh buckets.
+ *
+ * This order only contains headers written by infrastructure we sit behind.
+ * Cloudflare overwrites `cf-connecting-ip` on every request, so a forged value
+ * never survives the edge. `x-real-ip` is written by the reverse proxy for
+ * self-hosters running without Cloudflare.
+ */
+export const TRUSTED_IP_HEADER_ORDER = [
+ 'cf-connecting-ip',
+ 'x-real-ip',
+ 'x-forwarded-for',
+];
+
+/**
+ * Resolve the client IP for security decisions. Never returns an IP a client
+ * could have picked for itself.
+ *
+ * The order can be narrowed per deployment with `TRUSTED_IP_HEADER_ORDER`
+ * (comma separated) - set it to the single header your edge guarantees.
+ */
+export function getTrustedIpFromHeaders(
+ headers: Record<string, string | string[] | undefined> | Headers,
+ socketIp?: string,
+): { ip: string; header: string } {
+ const headerOrder = process.env.TRUSTED_IP_HEADER_ORDER
+ ? process.env.TRUSTED_IP_HEADER_ORDER.split(',').map((h) => h.trim())
+ : TRUSTED_IP_HEADER_ORDER;
+
+ for (const headerName of headerOrder) {
+ let value: string | null = null;
+
+ if (headers instanceof Headers) {
+ value = headers.get(headerName);
+ } else {
+ const headerValue = headers[headerName];
+ value = (Array.isArray(headerValue) ? headerValue[0] : headerValue) || null;
+ }
+
+ if (!value) continue;
+
+ // A proxy chain appends as it goes, so the *last* entry is the one written
+ // by the hop closest to us - the only entry a client cannot forge. This is
+ // the opposite of what `getClientIpFromHeaders` wants, which is why the two
+ // functions do not share this branch.
+ const candidate =
+ headerName === 'x-forwarded-for'
+ ? value.split(',').pop()?.trim()
+ : value.trim();
+
+ if (candidate && isValidIp(candidate)) {
+ return { ip: candidate, header: headerName };
+ }
+ }
+
+ // Direct connection (local dev, or an edge that strips everything). The
+ // socket address is by definition not client-controlled, so it is safe to
+ // use even when private.
+ if (socketIp) {
+ return { ip: socketIp, header: 'socket' };
+ }
+
+ return { ip: '', header: '' };
+}
diff --git a/packages/trpc/package.json b/packages/trpc/package.json
index 0efb2be59..0e841d803 100644
--- a/packages/trpc/package.json
+++ b/packages/trpc/package.json
@@ -21,7 +21,6 @@
"@openpanel/redis": "workspace:*",
"@openpanel/validation": "workspace:*",
"@openpanel/queue": "workspace:*",
- "@trpc-limiter/redis": "^0.0.2",
"@trpc/client": "^11.17.0",
"@trpc/server": "^11.17.0",
"date-fns": "^3.3.1",
diff --git a/packages/trpc/src/rate-limit.test.ts b/packages/trpc/src/rate-limit.test.ts
new file mode 100644
index 000000000..9ccb085df
--- /dev/null
+++ b/packages/trpc/src/rate-limit.test.ts
@@ -0,0 +1,29 @@
+import { describe, expect, it } from 'vitest';
+import { __testing } from './rate-limit';
+
+const { getBlockDurationMs, BLOCK_BASE_MS, BLOCK_MAX_MS, MAX_STRIKES } =
+ __testing;
+
+describe('rate limit escalation', () => {
+ it('doubles the lockout on every strike', () => {
+ expect(getBlockDurationMs(1)).toBe(BLOCK_BASE_MS);
+ expect(getBlockDurationMs(2)).toBe(BLOCK_BASE_MS * 2);
+ expect(getBlockDurationMs(3)).toBe(BLOCK_BASE_MS * 4);
+ expect(getBlockDurationMs(4)).toBe(BLOCK_BASE_MS * 8);
+ });
+
+ it('caps the lockout instead of overflowing into absurd durations', () => {
+ expect(getBlockDurationMs(MAX_STRIKES)).toBe(BLOCK_MAX_MS);
+ expect(getBlockDurationMs(1000)).toBe(BLOCK_MAX_MS);
+ });
+
+ it('reaches the cap at MAX_STRIKES and not before', () => {
+ expect(getBlockDurationMs(MAX_STRIKES - 1)).toBeLessThan(BLOCK_MAX_MS);
+ });
+
+ it('formats the wait as something a human can act on', () => {
+ expect(__testing.formatDuration(30_000)).toBe('30 seconds');
+ expect(__testing.formatDuration(5 * 60_000)).toBe('5 minutes');
+ expect(__testing.formatDuration(24 * 60 * 60_000)).toBe('24 hours');
+ });
+});
diff --git a/packages/trpc/src/rate-limit.ts b/packages/trpc/src/rate-limit.ts
new file mode 100644
index 000000000..10dd207d1
--- /dev/null
+++ b/packages/trpc/src/rate-limit.ts
@@ -0,0 +1,262 @@
+import { getTrustedIpFromHeaders } from '@openpanel/common/server/get-client-ip';
+import { LRUCache, getRedisCache } from '@openpanel/redis';
+import { TRPCError } from '@trpc/server';
+import type { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify';
+
+/** `fastify` is not a direct dependency here, so borrow the type tRPC exposes. */
+type FastifyRequest = CreateFastifyContextOptions['req'];
+
+const SECOND = 1000;
+const MINUTE = 60 * SECOND;
+const HOUR = 60 * MINUTE;
+
+/**
+ * The block handed out the first time a fingerprint blows through its window.
+ * It doubles on every further strike, so a client that keeps knocking walks
+ * 5m -> 10m -> 20m -> ... -> BLOCK_MAX_MS.
+ */
+const BLOCK_BASE_MS = 5 * MINUTE;
+const BLOCK_MAX_MS = 24 * HOUR;
+
+/**
+ * Strikes only decay after a full quiet day, and every new strike pushes the
+ * expiry out again. Sustained abuse therefore stays at the 24h block forever -
+ * the attacker has to actually stop to climb back down.
+ */
+const STRIKE_TTL_MS = 24 * HOUR;
+
+/** Past this the duration is capped anyway, so stop counting. */
+const MAX_STRIKES = Math.ceil(Math.log2(BLOCK_MAX_MS / BLOCK_BASE_MS)) + 1;
+
+/**
+ * A blocked client that keeps hammering earns further strikes, but at most one
+ * per cooldown. A human clicking "sign in" three more times in frustration adds
+ * one strike; a bot at 5 req/s reaches the 24h cap in under ten minutes.
+ */
+const ESCALATION_COOLDOWN_MS = MINUTE;
+
+export interface RateLimitOptions {
+ /** Requests allowed per window before the first block. */
+ max: number;
+ windowMs: number;
+}
+
+/**
+ * Per-process fallback used only while Redis is unreachable. Without it a Redis
+ * blip would leave the sign-in endpoint completely unthrottled.
+ */
+const fallbackCounters = new LRUCache<string, number>({
+ max: 10_000,
+ ttl: 5 * MINUTE,
+});
+
+const key = (kind: string, path: string, fingerprint: string) =>
+ `rl:${kind}:${path}:${fingerprint}`;
+
+function getBlockDurationMs(strikes: number): number {
+ return Math.min(BLOCK_BASE_MS * 2 ** (strikes - 1), BLOCK_MAX_MS);
+}
+
+function formatDuration(ms: number): string {
+ const seconds = Math.ceil(ms / SECOND);
+ if (seconds < 90) {
+ return `${seconds} seconds`;
+ }
+ const minutes = Math.ceil(seconds / 60);
+ if (minutes < 90) {
+ return `${minutes} minutes`;
+ }
+ return `${Math.ceil(minutes / 60)} hours`;
+}
+
+/**
+ * The identity we rate limit on. Deliberately ignores the client-forwarded IP
+ * headers that `getClientIpFromHeaders` prefers - those are attacker-controlled
+ * and would make every request its own bucket.
+ */
+export function getRateLimitIdentity(req: FastifyRequest) {
+ const { ip, header } = getTrustedIpFromHeaders(
+ req.headers,
+ req.socket?.remoteAddress,
+ );
+
+ return {
+ // Everything we cannot identify shares one bucket. Fail closed: an edge
+ // that stops forwarding IPs should throttle, not open the gates.
+ fingerprint: ip || 'unknown',
+ ipHeader: header,
+ };
+}
+
+function tooManyRequests(blockMs: number): TRPCError {
+ return new TRPCError({
+ code: 'TOO_MANY_REQUESTS',
+ message: `Too many requests. Try again in ${formatDuration(blockMs)}.`,
+ });
+}
+
+/**
+ * Record a strike and (re)arm the block. Returns the new strike count and how
+ * long the client is locked out for.
+ */
+async function escalate(strikeKey: string, blockKey: string, cooldownKey: string) {
+ const redis = getRedisCache();
+
+ // Counter and its expiry go out together: a strike key that lost its TTL
+ // would keep an IP at the maximum lockout forever.
+ const results = await redis
+ .pipeline()
+ .incr(strikeKey)
+ .pexpire(strikeKey, STRIKE_TTL_MS)
+ .exec();
+
+ const strikes = Math.min(Number(results?.[0]?.[1] ?? 1), MAX_STRIKES);
+ const blockMs = getBlockDurationMs(strikes);
+
+ await redis
+ .pipeline()
+ .set(blockKey, String(strikes), 'PX', blockMs)
+ .set(cooldownKey, '1', 'PX', ESCALATION_COOLDOWN_MS)
+ .exec();
+
+ return { strikes, blockMs };
+}
+
+/**
+ * IP rate limiting with exponential lockout.
+ *
+ * Blocks are keyed per procedure, so an office NAT that trips the sign-in limit
+ * does not lose the rest of the dashboard.
+ *
+ * Every block is logged as `rate limit blocked` with the resolved IP so
+ * repeat offenders can be pulled out of the logs and blackholed at the edge:
+ *
+ * SELECT LogAttributes['ip'], count() FROM otel_logs
+ * WHERE Body = 'rate limit blocked' GROUP BY 1 ORDER BY 2 DESC
+ */
+export async function enforceRateLimit({
+ req,
+ path,
+ max,
+ windowMs,
+}: RateLimitOptions & {
+ req: FastifyRequest;
+ /** tRPC procedure path - blocks are scoped to it. */
+ path: string;
+}): Promise<void> {
+ const { fingerprint, ipHeader } = getRateLimitIdentity(req);
+
+ const counterKey = key('count', path, fingerprint);
+ const strikeKey = key('strike', path, fingerprint);
+ const blockKey = key('block', path, fingerprint);
+ const cooldownKey = key('cooldown', path, fingerprint);
+
+ const log = (
+ message: string,
+ payload: { strikes: number; blockMs: number; hits?: number },
+ ) =>
+ req.log?.warn(
+ {
+ ip: fingerprint,
+ ipHeader,
+ path,
+ userAgent: req.headers['user-agent'],
+ strikes: payload.strikes,
+ blockedForSeconds: Math.ceil(payload.blockMs / SECOND),
+ blockedUntil: new Date(Date.now() + payload.blockMs).toISOString(),
+ hits: payload.hits,
+ max,
+ windowMs,
+ },
+ message,
+ );
+
+ let blockTtlMs: number;
+ let hits: number;
+
+ try {
+ const redis = getRedisCache();
+ const results = await redis
+ .pipeline()
+ .pttl(blockKey)
+ .pttl(counterKey)
+ .incr(counterKey)
+ .exec();
+
+ // `pttl` returns -2 when the key is gone and -1 when it has no expiry.
+ blockTtlMs = Number(results?.[0]?.[1] ?? -2);
+ const counterTtlMs = Number(results?.[1]?.[1] ?? -2);
+ hits = Number(results?.[2]?.[1] ?? 1);
+
+ // The window opens on the first hit. Re-arming a counter that somehow lost
+ // its expiry matters too: without a TTL it would count up forever and lock
+ // the IP out permanently after `max` requests.
+ if (hits === 1 || counterTtlMs === -1) {
+ await redis.pexpire(counterKey, windowMs);
+ }
+ } catch (error) {
+ req.log?.error({ err: error, path }, 'rate limit store unavailable');
+ const fallbackHits = (fallbackCounters.get(counterKey) ?? 0) + 1;
+ fallbackCounters.set(counterKey, fallbackHits, { ttl: windowMs });
+ if (fallbackHits > max) {
+ throw tooManyRequests(windowMs);
+ }
+ return;
+ }
+
+ if (blockTtlMs > 0) {
+ // Still locked out. Knocking during a block is itself abusive, so it
+ // extends the lockout instead of letting it run down - but at most once per
+ // cooldown, so a frustrated human cannot punish themselves the way a bot
+ // hammering at full speed does.
+ let escalated: { strikes: number; blockMs: number } | null = null;
+
+ try {
+ const acquired = await getRedisCache().set(
+ cooldownKey,
+ '1',
+ 'PX',
+ ESCALATION_COOLDOWN_MS,
+ 'NX',
+ );
+
+ if (acquired) {
+ escalated = await escalate(strikeKey, blockKey, cooldownKey);
+ }
+ } catch (error) {
+ req.log?.error({ err: error, path }, 'rate limit store unavailable');
+ }
+
+ if (!escalated) {
+ throw tooManyRequests(blockTtlMs);
+ }
+
+ log('rate limit blocked', escalated);
+ throw tooManyRequests(escalated.blockMs);
+ }
+
+ if (hits > max) {
+ let escalated: { strikes: number; blockMs: number };
+
+ try {
+ escalated = await escalate(strikeKey, blockKey, cooldownKey);
+ // Start the next window clean so the block, not a stale counter, decides.
+ await getRedisCache().del(counterKey);
+ } catch (error) {
+ req.log?.error({ err: error, path }, 'rate limit store unavailable');
+ throw tooManyRequests(windowMs);
+ }
+
+ log('rate limit blocked', { ...escalated, hits });
+ throw tooManyRequests(escalated.blockMs);
+ }
+}
+
+export const __testing = {
+ BLOCK_BASE_MS,
+ BLOCK_MAX_MS,
+ MAX_STRIKES,
+ ESCALATION_COOLDOWN_MS,
+ getBlockDurationMs,
+ formatDuration,
+};
diff --git a/packages/trpc/src/routers/auth.ts b/packages/trpc/src/routers/auth.ts
index e765bfdbb..5f7dec314 100644
--- a/packages/trpc/src/routers/auth.ts
+++ b/packages/trpc/src/routers/auth.ts
@@ -137,6 +137,12 @@ export const authRouter = createTRPCRouter({
};
}),
signUpEmail: publicProcedure
+ .use(
+ rateLimitMiddleware({
+ max: 5,
+ windowMs: 60_000,
+ })
+ )
.input(zSignUpEmail)
.mutation(async ({ input, ctx }) => {
const isRegistrationAllowed = await getIsRegistrationAllowed(
diff --git a/packages/trpc/src/trpc.ts b/packages/trpc/src/trpc.ts
index 23cd0cc79..3229fe5e9 100644
--- a/packages/trpc/src/trpc.ts
+++ b/packages/trpc/src/trpc.ts
@@ -8,29 +8,10 @@ import { COOKIE_OPTIONS, type SessionValidationResult } from '@openpanel/auth';
import { runWithAlsSession } from '@openpanel/db';
import { getRedisCache } from '@openpanel/redis';
import type { ISetCookie } from '@openpanel/validation';
-import {
- createTrpcRedisLimiter,
- defaultFingerPrint,
-} from '@trpc-limiter/redis';
+import { type RateLimitOptions, enforceRateLimit } from './rate-limit';
import { getOrganizationAccess, requireProjectAccess } from './access';
import { TRPCForbiddenError } from './errors';
-export const rateLimitMiddleware = ({
- max,
- windowMs,
-}: {
- max: number;
- windowMs: number;
-}) =>
- createTrpcRedisLimiter<typeof t>({
- fingerprint: (ctx) => defaultFingerPrint(ctx.req),
- message: (hitInfo) =>
- `Too many requests, please try again later. ${hitInfo}`,
- max,
- windowMs,
- redisClient: getRedisCache(),
- });
-
export async function createContext({ req, res }: CreateFastifyContextOptions) {
const cookies = (req as any).cookies as Record<string, string | undefined>;
const setCookie: ISetCookie = (key, value, options) => {
@@ -146,6 +127,17 @@ const enforceAccess = t.middleware(async ({ ctx, next, type, meta, getRawInput }
export const createTRPCRouter = t.router;
+/**
+ * Throttle a procedure by client IP, with an exponentially growing lockout for
+ * repeat offenders. See `./rate-limit` for the escalation rules and for the log
+ * line (`rate limit blocked`) that carries the offending IP.
+ */
+export const rateLimitMiddleware = (options: RateLimitOptions) =>
+ t.middleware(async ({ ctx, next, path }) => {
+ await enforceRateLimit({ req: ctx.req, path, ...options });
+ return next();
+ });
+
const loggerMiddleware = t.middleware(
async ({ ctx, next, getRawInput, path, input, type }) => {
const rawInput = await getRawInput();
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 70ababd8f..67f221141 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1912,9 +1912,6 @@ importers:
'@openpanel/validation':
specifier: workspace:*
version: link:../validation
- '@trpc-limiter/redis':
- specifier: ^0.0.2
'@trpc/client':
specifier: ^11.17.0
@@ -9419,21 +9416,6 @@ packages:
'@types/react-dom':
optional: true
- '@trpc-limiter/[email protected]':
- resolution: {integrity: sha512-Wjq2oTCmCdwNbZKRfKpzpl1Um9QXGE8OHXOab+EUSj5Wk+26I/V6Vs2p0VBFAz6eEsBn36982cCC/vaaznA8+Q==}
- engines: {node: '>=16'}
- peerDependencies:
- '@trpc/client': next
- '@trpc/server': next
-
- '@trpc-limiter/[email protected]':
- resolution: {integrity: sha512-Cfrk3YAC78yUJMl6eFl6TrU+nYYesJH7TXG+H1VH8UuT3kY3Ad/Wik/jdXyEMRg9VLSBsKhVYX6oD6jI+TTDTA==}
- engines: {node: '>=16'}
- peerDependencies:
- '@trpc/client': next
- '@trpc/server': next
- redis: ^4.6.13
-
resolution: {integrity: sha512-KpJBFrbKTDeVCFv/3ckL1XBBH5Yssn8hethI/rUy7GIpTj+VzjtPjykDqJpzobuVOz+d26cXCSu1t4I6MYI5Zg==}
hasBin: true
@@ -29979,19 +29961,6 @@ snapshots:
'@types/react': 19.2.7
'@types/react-dom': 19.2.3(@types/[email protected])
- dependencies:
- '@trpc/client': 11.17.0(@trpc/[email protected]([email protected]))([email protected])
- '@trpc/server': 11.17.0([email protected])
-
- dependencies:
- '@trpc/client': 11.17.0(@trpc/[email protected]([email protected]))([email protected])
- '@trpc/server': 11.17.0([email protected])
- rate-limiter-flexible: 5.0.4
- redis: 4.7.0
-
dependencies:
'@trpc/server': 11.17.0([email protected])