
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
@trpc-limiter/memory
Advanced tools
Memory store adapter for tRPC limiter.
npm install @trpc-limiter/memory@latest
import { initTRPC, TRPCError } from '@trpc/server'
import type { IContext } from './context'
import {
createTRPCStoreLimiter,
defaultFingerPrint,
} from '@trpc-limiter/memory'
type IContext = {
req: Request // your request type
}
export const root = initTRPC.context<IContext>().create()
const limiter = createTRPCStoreLimiter<typeof root>({
fingerprint: (ctx) => defaultFingerPrint(ctx.req),
windowMs: 20000,
message: (retryAfter) =>
`Too many requests, please try again later. ${retryAfter}`,
max: 15,
onLimit: (retryAfter, _ctx, fingerprint) => {
console.log(retryAfter, fingerprint)
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Too many requests unique',
})
},
})
export const rateLimitedProcedure = root.procedure.use(limiter)
import { initTRPC } from '@trpc/server'
import { type NextApiRequest } from 'next'
import {
createTRPCStoreLimiter,
defaultFingerPrint,
} from '@trpc-limiter/memory'
type Context = {
req: NextApiRequest
}
const t = initTRPC.context<Context>().create()
const rateLimiter = createTRPCStoreLimiter<typeof t>({
fingerprint: (ctx) => defaultFingerPrint(ctx.req),
message: (hitInfo) =>
`Too many requests, please try again later. ${Math.ceil(
(hitInfo.reset - Date.now()) / 1000
)}`,
max: 15,
windowMs: 10000,
})
export const rateLimitedProcedure = t.procedure.use(rateLimiter)
FAQs
Memory store adapter for tRPC limiter.
We found that @trpc-limiter/memory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.

Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.