examples: init
vi did:web:vt3e.cat
Wed, 08 Jul 2026 05:14:19 +0100
4 files changed,
103 insertions(+),
0 deletions(-)
A
pkgs/examples/.gitignore
@@ -0,0 +1,34 @@
+# dependencies (bun install) +node_modules + +# output +out +dist +*.tgz + +# code coverage +coverage +*.lcov + +# logs +logs +_.log +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# caches +.eslintcache +.cache +*.tsbuildinfo + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store
A
pkgs/examples/package.json
@@ -0,0 +1,16 @@
+{ + "name": "examples", + "private": true, + "type": "module", + "module": "index.ts", + "dependencies": { + "@purrkit/ratelimit": "workspace:*", + "@purrkit/rest": "workspace:*" + }, + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5" + } +}
A
pkgs/examples/src/index.ts
@@ -0,0 +1,23 @@
+import { RESTClient } from "@purrkit/rest"; +import { RateLimitManager } from "@purrkit/ratelimit"; + +const limiter = new RateLimitManager({ + onDebug: (msg, data) => { + console.log(`[REST Debug] ${msg}`, data || ""); + }, + onRateLimit: ({ routeId, global, delayMs, bucketHash }) => { + const type = global ? "GLOBAL" : "LOCAL"; + console.warn( + `[RateLimit] Hit ${type} limit on ${routeId}. Pausing for ${delayMs}ms (bucket: ${bucketHash})`, + ); + }, +}); + +const rest = RESTClient({ + token: process.env.TOKEN!, + fetch: limiter.fetch, +}); + +for (let i = 0; i < 50; i++) { + await rest.users.me.get(); +}
A
pkgs/examples/tsconfig.json
@@ -0,0 +1,30 @@
+{ + "compilerOptions": { + // Environment setup & latest features + "lib": ["ESNext"], + "target": "ESNext", + "module": "Preserve", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + "types": ["bun"], + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +}