claudeinone-cli 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -1
- package/kit/.claude/.ck.json +9 -0
- package/kit/.claude/.ckignore +12 -0
- package/kit/.claude/agents/accessibility-auditor.md +46 -0
- package/kit/.claude/agents/api-designer.md +43 -0
- package/kit/.claude/agents/backend-developer.md +54 -0
- package/kit/.claude/agents/brainstormer.md +33 -0
- package/kit/.claude/agents/campaign-manager.md +36 -0
- package/kit/.claude/agents/code-reviewer.md +39 -0
- package/kit/.claude/agents/content-creator.md +38 -0
- package/kit/.claude/agents/copywriter.md +42 -0
- package/kit/.claude/agents/database-admin.md +37 -0
- package/kit/.claude/agents/debugger.md +46 -0
- package/kit/.claude/agents/devops-engineer.md +41 -0
- package/kit/.claude/agents/docs-manager.md +33 -0
- package/kit/.claude/agents/email-wizard.md +40 -0
- package/kit/.claude/agents/frontend-developer.md +52 -0
- package/kit/.claude/agents/fullstack-developer.md +55 -0
- package/kit/.claude/agents/git-manager.md +40 -0
- package/kit/.claude/agents/i18n-specialist.md +46 -0
- package/kit/.claude/agents/integration-specialist.md +48 -0
- package/kit/.claude/agents/journal-writer.md +39 -0
- package/kit/.claude/agents/mcp-manager.md +57 -0
- package/kit/.claude/agents/mobile-developer.md +38 -0
- package/kit/.claude/agents/performance-optimizer.md +38 -0
- package/kit/.claude/agents/planner.md +56 -0
- package/kit/.claude/agents/project-manager.md +34 -0
- package/kit/.claude/agents/refactorer.md +43 -0
- package/kit/.claude/agents/researcher.md +45 -0
- package/kit/.claude/agents/risk-analyst.md +33 -0
- package/kit/.claude/agents/scalability-consultant.md +39 -0
- package/kit/.claude/agents/scout.md +25 -0
- package/kit/.claude/agents/security-auditor.md +42 -0
- package/kit/.claude/agents/seo-specialist.md +44 -0
- package/kit/.claude/agents/skill-creator.md +64 -0
- package/kit/.claude/agents/social-media-manager.md +35 -0
- package/kit/.claude/agents/systems-designer.md +35 -0
- package/kit/.claude/agents/technology-strategist.md +43 -0
- package/kit/.claude/agents/tester.md +40 -0
- package/kit/.claude/agents/ui-ux-designer.md +40 -0
- package/kit/.claude/commands/co/ask.md +29 -0
- package/kit/.claude/commands/co/bootstrap-auto-fast.md +28 -0
- package/kit/.claude/commands/co/bootstrap-auto-parallel.md +29 -0
- package/kit/.claude/commands/co/bootstrap-auto.md +30 -0
- package/kit/.claude/commands/co/bootstrap.md +31 -0
- package/kit/.claude/commands/co/brainstorm.md +27 -0
- package/kit/.claude/commands/co/campaign.md +28 -0
- package/kit/.claude/commands/co/changelog.md +25 -0
- package/kit/.claude/commands/co/checkpoint.md +25 -0
- package/kit/.claude/commands/co/ci.md +26 -0
- package/kit/.claude/commands/co/ck-help.md +24 -0
- package/kit/.claude/commands/co/coding-level.md +24 -0
- package/kit/.claude/commands/co/content-cro.md +26 -0
- package/kit/.claude/commands/co/content-enhance.md +26 -0
- package/kit/.claude/commands/co/content-fast.md +24 -0
- package/kit/.claude/commands/co/content-good.md +26 -0
- package/kit/.claude/commands/co/cook.md +33 -0
- package/kit/.claude/commands/co/debug.md +26 -0
- package/kit/.claude/commands/co/deploy.md +25 -0
- package/kit/.claude/commands/co/design-3d.md +27 -0
- package/kit/.claude/commands/co/design-describe.md +25 -0
- package/kit/.claude/commands/co/design-fast.md +25 -0
- package/kit/.claude/commands/co/design-good.md +28 -0
- package/kit/.claude/commands/co/design-screenshot.md +26 -0
- package/kit/.claude/commands/co/design-video.md +26 -0
- package/kit/.claude/commands/co/docker.md +24 -0
- package/kit/.claude/commands/co/docs-api.md +25 -0
- package/kit/.claude/commands/co/docs-init.md +26 -0
- package/kit/.claude/commands/co/docs-readme.md +24 -0
- package/kit/.claude/commands/co/docs-summarize.md +25 -0
- package/kit/.claude/commands/co/docs-update.md +25 -0
- package/kit/.claude/commands/co/env-check.md +25 -0
- package/kit/.claude/commands/co/fix-ci.md +29 -0
- package/kit/.claude/commands/co/fix-fast.md +28 -0
- package/kit/.claude/commands/co/fix-hard.md +33 -0
- package/kit/.claude/commands/co/fix-logs.md +28 -0
- package/kit/.claude/commands/co/fix-types.md +28 -0
- package/kit/.claude/commands/co/fix-ui.md +28 -0
- package/kit/.claude/commands/co/fix.md +27 -0
- package/kit/.claude/commands/co/git-cm.md +26 -0
- package/kit/.claude/commands/co/git-cp.md +26 -0
- package/kit/.claude/commands/co/git-pr.md +26 -0
- package/kit/.claude/commands/co/index.md +24 -0
- package/kit/.claude/commands/co/integrate-polar.md +29 -0
- package/kit/.claude/commands/co/integrate-sepay.md +29 -0
- package/kit/.claude/commands/co/journal.md +27 -0
- package/kit/.claude/commands/co/k8s.md +24 -0
- package/kit/.claude/commands/co/kanban.md +25 -0
- package/kit/.claude/commands/co/lint-fix.md +24 -0
- package/kit/.claude/commands/co/load.md +25 -0
- package/kit/.claude/commands/co/migrate.md +28 -0
- package/kit/.claude/commands/co/mock.md +26 -0
- package/kit/.claude/commands/co/mode.md +24 -0
- package/kit/.claude/commands/co/monitor.md +25 -0
- package/kit/.claude/commands/co/new-feature.md +27 -0
- package/kit/.claude/commands/co/optimize.md +26 -0
- package/kit/.claude/commands/co/plan-archive.md +24 -0
- package/kit/.claude/commands/co/plan-ci.md +28 -0
- package/kit/.claude/commands/co/plan-cro.md +27 -0
- package/kit/.claude/commands/co/plan-fast.md +24 -0
- package/kit/.claude/commands/co/plan-hard.md +27 -0
- package/kit/.claude/commands/co/plan-parallel.md +25 -0
- package/kit/.claude/commands/co/plan-two.md +29 -0
- package/kit/.claude/commands/co/plan-validate.md +27 -0
- package/kit/.claude/commands/co/plan.md +27 -0
- package/kit/.claude/commands/co/pr.md +25 -0
- package/kit/.claude/commands/co/preview.md +26 -0
- package/kit/.claude/commands/co/refactor.md +25 -0
- package/kit/.claude/commands/co/release.md +25 -0
- package/kit/.claude/commands/co/review-a11y.md +24 -0
- package/kit/.claude/commands/co/review-codebase-parallel.md +27 -0
- package/kit/.claude/commands/co/review-codebase.md +27 -0
- package/kit/.claude/commands/co/review-perf.md +24 -0
- package/kit/.claude/commands/co/review-security.md +25 -0
- package/kit/.claude/commands/co/scaffold.md +25 -0
- package/kit/.claude/commands/co/scout.md +26 -0
- package/kit/.claude/commands/co/secure.md +26 -0
- package/kit/.claude/commands/co/seed.md +25 -0
- package/kit/.claude/commands/co/seo-audit.md +24 -0
- package/kit/.claude/commands/co/seo-keywords.md +25 -0
- package/kit/.claude/commands/co/skill-create.md +29 -0
- package/kit/.claude/commands/co/skill-fix-logs.md +28 -0
- package/kit/.claude/commands/co/slide-create.md +24 -0
- package/kit/.claude/commands/co/spawn.md +24 -0
- package/kit/.claude/commands/co/terraform.md +24 -0
- package/kit/.claude/commands/co/test-gen.md +24 -0
- package/kit/.claude/commands/co/test-ui.md +27 -0
- package/kit/.claude/commands/co/test.md +26 -0
- package/kit/.claude/commands/co/use-mcp.md +25 -0
- package/kit/.claude/commands/co/video-script.md +25 -0
- package/kit/.claude/commands/co/watzup.md +25 -0
- package/kit/.claude/commands/co/worktree.md +25 -0
- package/kit/.claude/commands/co/write-blog.md +25 -0
- package/kit/.claude/commands/co/write-copy.md +24 -0
- package/kit/.claude/commands/co/write-email.md +25 -0
- package/kit/.claude/commands/content/content-cro.md +26 -0
- package/kit/.claude/commands/content/content-enhance.md +26 -0
- package/kit/.claude/commands/content/content-fast.md +24 -0
- package/kit/.claude/commands/content/content-good.md +26 -0
- package/kit/.claude/commands/content/enhance.md +26 -0
- package/kit/.claude/commands/content/good.md +26 -0
- package/kit/.claude/commands/core/ask.md +29 -0
- package/kit/.claude/commands/core/bootstrap-auto-fast.md +28 -0
- package/kit/.claude/commands/core/bootstrap-auto-parallel.md +29 -0
- package/kit/.claude/commands/core/bootstrap-auto.md +30 -0
- package/kit/.claude/commands/core/bootstrap.md +31 -0
- package/kit/.claude/commands/core/ck-help.md +24 -0
- package/kit/.claude/commands/core/coding-level.md +24 -0
- package/kit/.claude/commands/core/cook.md +33 -0
- package/kit/.claude/commands/core/debug.md +26 -0
- package/kit/.claude/commands/core/journal.md +27 -0
- package/kit/.claude/commands/core/kanban.md +25 -0
- package/kit/.claude/commands/core/preview.md +26 -0
- package/kit/.claude/commands/core/scout.md +26 -0
- package/kit/.claude/commands/core/test-ui.md +27 -0
- package/kit/.claude/commands/core/test.md +26 -0
- package/kit/.claude/commands/core/use-mcp.md +25 -0
- package/kit/.claude/commands/core/watzup.md +25 -0
- package/kit/.claude/commands/core/worktree.md +25 -0
- package/kit/.claude/commands/design/3d.md +27 -0
- package/kit/.claude/commands/design/design-3d.md +27 -0
- package/kit/.claude/commands/design/design-describe.md +25 -0
- package/kit/.claude/commands/design/design-fast.md +25 -0
- package/kit/.claude/commands/design/design-good.md +28 -0
- package/kit/.claude/commands/design/design-screenshot.md +26 -0
- package/kit/.claude/commands/design/design-video.md +26 -0
- package/kit/.claude/commands/design/good.md +28 -0
- package/kit/.claude/commands/design/video.md +26 -0
- package/kit/.claude/commands/docs/docs-init.md +26 -0
- package/kit/.claude/commands/docs/docs-summarize.md +25 -0
- package/kit/.claude/commands/docs/docs-update.md +25 -0
- package/kit/.claude/commands/docs/init.md +26 -0
- package/kit/.claude/commands/docs/summarize.md +25 -0
- package/kit/.claude/commands/fix/ci.md +29 -0
- package/kit/.claude/commands/fix/fast.md +28 -0
- package/kit/.claude/commands/fix/fix-ci.md +29 -0
- package/kit/.claude/commands/fix/fix-fast.md +28 -0
- package/kit/.claude/commands/fix/fix-hard.md +33 -0
- package/kit/.claude/commands/fix/fix-logs.md +28 -0
- package/kit/.claude/commands/fix/fix-types.md +28 -0
- package/kit/.claude/commands/fix/fix-ui.md +28 -0
- package/kit/.claude/commands/fix/hard.md +33 -0
- package/kit/.claude/commands/fix/logs.md +28 -0
- package/kit/.claude/commands/fix/types.md +28 -0
- package/kit/.claude/commands/fix/ui.md +28 -0
- package/kit/.claude/commands/git/cp.md +26 -0
- package/kit/.claude/commands/git/git-cm.md +26 -0
- package/kit/.claude/commands/git/git-cp.md +26 -0
- package/kit/.claude/commands/git/git-pr.md +26 -0
- package/kit/.claude/commands/integrate/integrate-polar.md +29 -0
- package/kit/.claude/commands/integrate/integrate-sepay.md +29 -0
- package/kit/.claude/commands/integrate/sepay.md +29 -0
- package/kit/.claude/commands/plan/ci.md +28 -0
- package/kit/.claude/commands/plan/cro.md +27 -0
- package/kit/.claude/commands/plan/hard.md +27 -0
- package/kit/.claude/commands/plan/plan-archive.md +24 -0
- package/kit/.claude/commands/plan/plan-ci.md +28 -0
- package/kit/.claude/commands/plan/plan-cro.md +27 -0
- package/kit/.claude/commands/plan/plan-fast.md +24 -0
- package/kit/.claude/commands/plan/plan-hard.md +27 -0
- package/kit/.claude/commands/plan/plan-parallel.md +25 -0
- package/kit/.claude/commands/plan/plan-two.md +29 -0
- package/kit/.claude/commands/plan/plan-validate.md +27 -0
- package/kit/.claude/commands/plan/plan.md +27 -0
- package/kit/.claude/commands/plan/validate.md +27 -0
- package/kit/.claude/commands/skill/fix-logs.md +28 -0
- package/kit/.claude/commands/skill/skill-create.md +29 -0
- package/kit/.claude/commands/skill/skill-fix-logs.md +28 -0
- package/kit/.claude/settings.json +16 -0
- package/kit/.claude/skills/ai-anthropic.md +100 -0
- package/kit/.claude/skills/ai-context-engineering.md +113 -0
- package/kit/.claude/skills/ai-gemini.md +152 -0
- package/kit/.claude/skills/ai-langchain.md +93 -0
- package/kit/.claude/skills/ai-llamaindex.md +179 -0
- package/kit/.claude/skills/ai-mcp-builder.md +101 -0
- package/kit/.claude/skills/ai-openai.md +250 -0
- package/kit/.claude/skills/ai-prompt-engineering.md +173 -0
- package/kit/.claude/skills/ai-rag.md +91 -0
- package/kit/.claude/skills/ai-vectordb.md +215 -0
- package/kit/.claude/skills/analytics-segment.md +161 -0
- package/kit/.claude/skills/api-caching.md +103 -0
- package/kit/.claude/skills/api-documentation.md +50 -0
- package/kit/.claude/skills/api-graphql.md +234 -0
- package/kit/.claude/skills/api-openapi.md +116 -0
- package/kit/.claude/skills/api-pagination-filtering.md +239 -0
- package/kit/.claude/skills/api-rate-limiting.md +179 -0
- package/kit/.claude/skills/api-rest-advanced.md +50 -0
- package/kit/.claude/skills/api-rest.md +217 -0
- package/kit/.claude/skills/api-trpc.md +173 -0
- package/kit/.claude/skills/api-versioning.md +70 -0
- package/kit/.claude/skills/api-webhooks.md +226 -0
- package/kit/.claude/skills/arch-clean-code.md +226 -0
- package/kit/.claude/skills/arch-clean.md +91 -0
- package/kit/.claude/skills/arch-cqrs.md +229 -0
- package/kit/.claude/skills/arch-ddd.md +85 -0
- package/kit/.claude/skills/arch-event-driven.md +189 -0
- package/kit/.claude/skills/arch-microservices.md +80 -0
- package/kit/.claude/skills/arch-monorepo.md +87 -0
- package/kit/.claude/skills/arch-multi-tenant.md +81 -0
- package/kit/.claude/skills/arch-serverless.md +86 -0
- package/kit/.claude/skills/auth-clerk.md +97 -0
- package/kit/.claude/skills/auth-jwt.md +143 -0
- package/kit/.claude/skills/auth-lucia.md +93 -0
- package/kit/.claude/skills/auth-nextauth.md +446 -0
- package/kit/.claude/skills/auth-oauth.md +208 -0
- package/kit/.claude/skills/auth-oauth2.md +110 -0
- package/kit/.claude/skills/auth-passkeys.md +109 -0
- package/kit/.claude/skills/auth-session.md +88 -0
- package/kit/.claude/skills/backend-dotnet.md +414 -0
- package/kit/.claude/skills/backend-express.md +129 -0
- package/kit/.claude/skills/backend-fastify.md +104 -0
- package/kit/.claude/skills/backend-go.md +205 -0
- package/kit/.claude/skills/backend-graphql.md +149 -0
- package/kit/.claude/skills/backend-grpc.md +382 -0
- package/kit/.claude/skills/backend-hono.md +95 -0
- package/kit/.claude/skills/backend-java-spring.md +198 -0
- package/kit/.claude/skills/backend-nodejs-express.md +165 -0
- package/kit/.claude/skills/backend-nodejs.md +143 -0
- package/kit/.claude/skills/backend-php-laravel.md +156 -0
- package/kit/.claude/skills/backend-python-django.md +200 -0
- package/kit/.claude/skills/backend-python-fastapi.md +169 -0
- package/kit/.claude/skills/backend-ruby-rails.md +190 -0
- package/kit/.claude/skills/backend-rust.md +182 -0
- package/kit/.claude/skills/backend-websockets.md +392 -0
- package/kit/.claude/skills/cache-redis.md +195 -0
- package/kit/.claude/skills/caching-strategies.md +100 -0
- package/kit/.claude/skills/cloud-aws.md +165 -0
- package/kit/.claude/skills/cloud-azure.md +187 -0
- package/kit/.claude/skills/cloud-cloudflare.md +74 -0
- package/kit/.claude/skills/cloud-fly.md +94 -0
- package/kit/.claude/skills/cloud-gcp.md +160 -0
- package/kit/.claude/skills/cloud-railway.md +92 -0
- package/kit/.claude/skills/cloud-render.md +70 -0
- package/kit/.claude/skills/cloud-serverless.md +68 -0
- package/kit/.claude/skills/cloud-vercel.md +76 -0
- package/kit/.claude/skills/component-patterns.md +50 -0
- package/kit/.claude/skills/content-management.md +197 -0
- package/kit/.claude/skills/cors-security.md +50 -0
- package/kit/.claude/skills/data-csv-excel.md +210 -0
- package/kit/.claude/skills/database-optimization.md +196 -0
- package/kit/.claude/skills/databases-transactions.md +68 -0
- package/kit/.claude/skills/db-cassandra.md +89 -0
- package/kit/.claude/skills/db-drizzle.md +363 -0
- package/kit/.claude/skills/db-dynamodb.md +83 -0
- package/kit/.claude/skills/db-elasticsearch.md +105 -0
- package/kit/.claude/skills/db-firebase-firestore.md +191 -0
- package/kit/.claude/skills/db-mongodb.md +198 -0
- package/kit/.claude/skills/db-mysql.md +50 -0
- package/kit/.claude/skills/db-neon.md +72 -0
- package/kit/.claude/skills/db-planetscale.md +76 -0
- package/kit/.claude/skills/db-postgresql.md +50 -0
- package/kit/.claude/skills/db-prisma.md +414 -0
- package/kit/.claude/skills/db-redis.md +50 -0
- package/kit/.claude/skills/db-sqlite.md +149 -0
- package/kit/.claude/skills/db-supabase.md +445 -0
- package/kit/.claude/skills/devops-ci-cd.md +271 -0
- package/kit/.claude/skills/devops-database-backup.md +77 -0
- package/kit/.claude/skills/devops-docker.md +93 -0
- package/kit/.claude/skills/devops-github-actions.md +82 -0
- package/kit/.claude/skills/devops-health-checks.md +50 -0
- package/kit/.claude/skills/devops-kubernetes.md +109 -0
- package/kit/.claude/skills/devops-logging.md +163 -0
- package/kit/.claude/skills/devops-monitoring.md +203 -0
- package/kit/.claude/skills/devops-pulumi.md +94 -0
- package/kit/.claude/skills/devops-secrets.md +166 -0
- package/kit/.claude/skills/devops-terraform.md +226 -0
- package/kit/.claude/skills/error-boundaries.md +84 -0
- package/kit/.claude/skills/file-storage.md +50 -0
- package/kit/.claude/skills/frontend-angular.md +104 -0
- package/kit/.claude/skills/frontend-astro.md +94 -0
- package/kit/.claude/skills/frontend-bundle-analysis.md +147 -0
- package/kit/.claude/skills/frontend-forms.md +134 -0
- package/kit/.claude/skills/frontend-htmx.md +86 -0
- package/kit/.claude/skills/frontend-nextjs.md +188 -0
- package/kit/.claude/skills/frontend-pwa.md +105 -0
- package/kit/.claude/skills/frontend-react-hooks.md +238 -0
- package/kit/.claude/skills/frontend-react.md +129 -0
- package/kit/.claude/skills/frontend-remix-advanced.md +106 -0
- package/kit/.claude/skills/frontend-remix.md +101 -0
- package/kit/.claude/skills/frontend-solid.md +99 -0
- package/kit/.claude/skills/frontend-state-management.md +134 -0
- package/kit/.claude/skills/frontend-state.md +106 -0
- package/kit/.claude/skills/frontend-svelte.md +121 -0
- package/kit/.claude/skills/frontend-testing.md +100 -0
- package/kit/.claude/skills/frontend-vite.md +94 -0
- package/kit/.claude/skills/frontend-vue.md +133 -0
- package/kit/.claude/skills/frontend-webpack.md +93 -0
- package/kit/.claude/skills/functional-programming.md +50 -0
- package/kit/.claude/skills/hooks-custom.md +50 -0
- package/kit/.claude/skills/http-server.md +50 -0
- package/kit/.claude/skills/i18n-general.md +89 -0
- package/kit/.claude/skills/i18n-localization.md +191 -0
- package/kit/.claude/skills/i18n-nextjs.md +127 -0
- package/kit/.claude/skills/infrastructure-docker-compose.md +77 -0
- package/kit/.claude/skills/infrastructure-serverless.md +177 -0
- package/kit/.claude/skills/jwt-tokens.md +50 -0
- package/kit/.claude/skills/logging-winston.md +106 -0
- package/kit/.claude/skills/messaging-kafka.md +102 -0
- package/kit/.claude/skills/messaging-rabbitmq.md +50 -0
- package/kit/.claude/skills/mobile-capacitor.md +109 -0
- package/kit/.claude/skills/mobile-expo.md +101 -0
- package/kit/.claude/skills/mobile-flutter.md +259 -0
- package/kit/.claude/skills/mobile-react-native.md +238 -0
- package/kit/.claude/skills/monitoring-apm.md +50 -0
- package/kit/.claude/skills/monitoring-error-tracking.md +217 -0
- package/kit/.claude/skills/nodejs-streams.md +168 -0
- package/kit/.claude/skills/oauth-integration.md +50 -0
- package/kit/.claude/skills/patterns-dependency-injection.md +218 -0
- package/kit/.claude/skills/patterns-factory-singleton.md +209 -0
- package/kit/.claude/skills/patterns-observer-pubsub.md +210 -0
- package/kit/.claude/skills/payment-lemonsqueezy.md +101 -0
- package/kit/.claude/skills/payment-square.md +178 -0
- package/kit/.claude/skills/payment-stripe.md +206 -0
- package/kit/.claude/skills/perf-bundle.md +100 -0
- package/kit/.claude/skills/perf-web-vitals.md +102 -0
- package/kit/.claude/skills/performance-database-connection-pooling.md +67 -0
- package/kit/.claude/skills/performance-metrics.md +73 -0
- package/kit/.claude/skills/performance-optimization.md +208 -0
- package/kit/.claude/skills/performance-web-vitals.md +169 -0
- package/kit/.claude/skills/rate-limiting.md +77 -0
- package/kit/.claude/skills/reactive-programming.md +50 -0
- package/kit/.claude/skills/realtime-database.md +50 -0
- package/kit/.claude/skills/realtime-subscriptions.md +218 -0
- package/kit/.claude/skills/saas-ab-testing.md +90 -0
- package/kit/.claude/skills/saas-analytics.md +113 -0
- package/kit/.claude/skills/saas-billing.md +106 -0
- package/kit/.claude/skills/saas-email.md +88 -0
- package/kit/.claude/skills/saas-feature-flags.md +83 -0
- package/kit/.claude/skills/saas-onboarding.md +96 -0
- package/kit/.claude/skills/saas-user-onboarding.md +207 -0
- package/kit/.claude/skills/security-encryption.md +216 -0
- package/kit/.claude/skills/security-owasp.md +212 -0
- package/kit/.claude/skills/security-secrets-rotation.md +64 -0
- package/kit/.claude/skills/seo-content.md +94 -0
- package/kit/.claude/skills/seo-technical.md +101 -0
- package/kit/.claude/skills/serverless-framework.md +151 -0
- package/kit/.claude/skills/sharding-scaling.md +50 -0
- package/kit/.claude/skills/styling-css-modules.md +219 -0
- package/kit/.claude/skills/styling-styled-components.md +206 -0
- package/kit/.claude/skills/styling-tailwind.md +206 -0
- package/kit/.claude/skills/test-e2e.md +86 -0
- package/kit/.claude/skills/test-integration.md +216 -0
- package/kit/.claude/skills/test-performance.md +162 -0
- package/kit/.claude/skills/test-tdd.md +170 -0
- package/kit/.claude/skills/test-unit.md +301 -0
- package/kit/.claude/skills/testing-accessibility.md +117 -0
- package/kit/.claude/skills/testing-contract.md +75 -0
- package/kit/.claude/skills/testing-e2e-advanced.md +50 -0
- package/kit/.claude/skills/testing-load-stress.md +79 -0
- package/kit/.claude/skills/testing-mutation.md +92 -0
- package/kit/.claude/skills/testing-snapshot.md +50 -0
- package/kit/.claude/skills/testing-vitest.md +172 -0
- package/kit/.claude/skills/tooling-biome.md +91 -0
- package/kit/.claude/skills/tooling-build-tools.md +166 -0
- package/kit/.claude/skills/tooling-bun.md +94 -0
- package/kit/.claude/skills/tooling-eslint.md +103 -0
- package/kit/.claude/skills/tooling-git.md +79 -0
- package/kit/.claude/skills/tooling-monorepo.md +162 -0
- package/kit/.claude/skills/tooling-testing-frameworks.md +207 -0
- package/kit/.claude/skills/tooling-typescript.md +156 -0
- package/kit/.claude/skills/ui-a11y.md +106 -0
- package/kit/.claude/skills/ui-framer.md +106 -0
- package/kit/.claude/skills/ui-gsap.md +102 -0
- package/kit/.claude/skills/ui-radix.md +82 -0
- package/kit/.claude/skills/ui-shadcn.md +463 -0
- package/kit/.claude/skills/ui-tailwind.md +98 -0
- package/kit/.claude/skills/ui-threejs.md +110 -0
- package/kit/.claude/skills/ui-tokens.md +97 -0
- package/kit/.claude/skills/utilities-date-time.md +170 -0
- package/kit/.claude/skills/validation-schemas.md +110 -0
- package/kit/.claude/skills/version-control-git.md +144 -0
- package/kit/.claude/skills/web-accessibility-wcag.md +102 -0
- package/kit/.claude/skills/web-astro.md +197 -0
- package/kit/.claude/skills/web-html-css.md +224 -0
- package/kit/.claude/skills/web-htmx.md +99 -0
- package/kit/.claude/skills/web-nextjs-advanced.md +202 -0
- package/kit/.claude/skills/web-remix.md +194 -0
- package/kit/.claude/skills/web-seo.md +99 -0
- package/kit/.claude/skills/web-svelte.md +234 -0
- package/kit/.claude/skills/websocket-server.md +50 -0
- package/kit/.claude/skills/writing-marketing.md +89 -0
- package/kit/.claude/skills/writing-technical.md +119 -0
- package/kit/CLAUDE.md +206 -0
- package/kit/README.md +150 -0
- package/kit/SKILLS_INDEX.md +188 -0
- package/kit/docs/README.md +3 -0
- package/kit/journals/README.md +3 -0
- package/kit/plans/README.md +3 -0
- package/package.json +3 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Rust
|
|
2
|
+
|
|
3
|
+
Systems language with memory safety without garbage collection, ideal for performance-critical applications.
|
|
4
|
+
|
|
5
|
+
## Basic Syntax
|
|
6
|
+
|
|
7
|
+
```rust
|
|
8
|
+
fn main() {
|
|
9
|
+
let x = 5; // immutable
|
|
10
|
+
let mut y = 5; // mutable
|
|
11
|
+
y += 1;
|
|
12
|
+
|
|
13
|
+
let s = String::from("hello");
|
|
14
|
+
println!("{}", s);
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Ownership & Borrowing
|
|
19
|
+
|
|
20
|
+
```rust
|
|
21
|
+
// Ownership
|
|
22
|
+
let s1 = String::from("hello");
|
|
23
|
+
let s2 = s1; // s1 no longer valid
|
|
24
|
+
|
|
25
|
+
// Borrowing (references)
|
|
26
|
+
let s1 = String::from("hello");
|
|
27
|
+
let len = calculate_length(&s1); // borrow, don't take ownership
|
|
28
|
+
|
|
29
|
+
fn calculate_length(s: &String) -> usize {
|
|
30
|
+
s.len()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Mutable borrow
|
|
34
|
+
let mut s = String::from("hello");
|
|
35
|
+
change_string(&mut s);
|
|
36
|
+
|
|
37
|
+
fn change_string(s: &mut String) {
|
|
38
|
+
s.push_str(" world");
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Result & Error Handling
|
|
43
|
+
|
|
44
|
+
```rust
|
|
45
|
+
use std::fs::File;
|
|
46
|
+
use std::io::Read;
|
|
47
|
+
|
|
48
|
+
fn read_file(path: &str) -> Result<String, std::io::Error> {
|
|
49
|
+
let mut file = File::open(path)?; // propagate error
|
|
50
|
+
let mut contents = String::new();
|
|
51
|
+
file.read_to_string(&mut contents)?;
|
|
52
|
+
Ok(contents)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Match on Result
|
|
56
|
+
match read_file("file.txt") {
|
|
57
|
+
Ok(content) => println!("{}", content),
|
|
58
|
+
Err(e) => eprintln!("Error: {}", e),
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Web Server with Actix
|
|
63
|
+
|
|
64
|
+
```rust
|
|
65
|
+
use actix_web::{web, App, HttpServer, HttpResponse};
|
|
66
|
+
use serde::{Deserialize, Serialize};
|
|
67
|
+
|
|
68
|
+
#[derive(Serialize, Deserialize)]
|
|
69
|
+
struct User {
|
|
70
|
+
id: u32,
|
|
71
|
+
name: String,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async fn get_user(id: web::Path<u32>) -> HttpResponse {
|
|
75
|
+
let user = User {
|
|
76
|
+
id: id.into_inner(),
|
|
77
|
+
name: "John".to_string(),
|
|
78
|
+
};
|
|
79
|
+
HttpResponse::Ok().json(user)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async fn create_user(user: web::Json<User>) -> HttpResponse {
|
|
83
|
+
HttpResponse::Created().json(user.into_inner())
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#[actix_web::main]
|
|
87
|
+
async fn main() -> std::io::Result<()> {
|
|
88
|
+
HttpServer::new(|| {
|
|
89
|
+
App::new()
|
|
90
|
+
.route("/users/{id}", web::get().to(get_user))
|
|
91
|
+
.route("/users", web::post().to(create_user))
|
|
92
|
+
})
|
|
93
|
+
.bind("127.0.0.1:8080")?
|
|
94
|
+
.run()
|
|
95
|
+
.await
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Traits & Generics
|
|
100
|
+
|
|
101
|
+
```rust
|
|
102
|
+
trait Drawable {
|
|
103
|
+
fn draw(&self);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
struct Circle {
|
|
107
|
+
radius: f64,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
impl Drawable for Circle {
|
|
111
|
+
fn draw(&self) {
|
|
112
|
+
println!("Drawing circle with radius {}", self.radius);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Generics
|
|
117
|
+
fn largest<T: PartialOrd + Copy>(list: &[T]) -> T {
|
|
118
|
+
let mut largest = list[0];
|
|
119
|
+
for &item in list {
|
|
120
|
+
if item > largest {
|
|
121
|
+
largest = item;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
largest
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Async/Await
|
|
129
|
+
|
|
130
|
+
```rust
|
|
131
|
+
use tokio::task;
|
|
132
|
+
|
|
133
|
+
async fn fetch_data(url: &str) -> Result<String, reqwest::Error> {
|
|
134
|
+
let response = reqwest::get(url).await?;
|
|
135
|
+
response.text().await
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
#[tokio::main]
|
|
139
|
+
async fn main() {
|
|
140
|
+
let data = fetch_data("https://api.example.com/data").await;
|
|
141
|
+
match data {
|
|
142
|
+
Ok(body) => println!("{}", body),
|
|
143
|
+
Err(e) => eprintln!("Error: {}", e),
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Testing
|
|
149
|
+
|
|
150
|
+
```rust
|
|
151
|
+
#[cfg(test)]
|
|
152
|
+
mod tests {
|
|
153
|
+
use super::*;
|
|
154
|
+
|
|
155
|
+
#[test]
|
|
156
|
+
fn test_addition() {
|
|
157
|
+
assert_eq!(2 + 2, 4);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#[test]
|
|
161
|
+
#[should_panic]
|
|
162
|
+
fn test_panic() {
|
|
163
|
+
panic!("This test panics");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Best Practices
|
|
169
|
+
|
|
170
|
+
1. **Leverage the type system**
|
|
171
|
+
2. **Use Option/Result for safety**
|
|
172
|
+
3. **Write idiomatic Rust code**
|
|
173
|
+
4. **Use lifetimes correctly**
|
|
174
|
+
5. **Implement proper error handling**
|
|
175
|
+
6. **Use async/await for concurrency**
|
|
176
|
+
7. **Write comprehensive tests**
|
|
177
|
+
|
|
178
|
+
## Resources
|
|
179
|
+
|
|
180
|
+
- [The Rust Book](https://doc.rust-lang.org/book/)
|
|
181
|
+
- [Rust by Example](https://doc.rust-lang.org/rust-by-example/)
|
|
182
|
+
- [Actix Documentation](https://actix.rs/)
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# WebSockets
|
|
2
|
+
|
|
3
|
+
Bidirectional real-time communication between client and server.
|
|
4
|
+
|
|
5
|
+
## Setup with ws Library
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install ws
|
|
9
|
+
npm install -D @types/ws # TypeScript
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Basic Server
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
const WebSocket = require('ws');
|
|
16
|
+
const http = require('http');
|
|
17
|
+
|
|
18
|
+
const server = http.createServer();
|
|
19
|
+
const wss = new WebSocket.Server({ server });
|
|
20
|
+
|
|
21
|
+
wss.on('connection', (ws) => {
|
|
22
|
+
console.log('Client connected');
|
|
23
|
+
|
|
24
|
+
// Send message to client
|
|
25
|
+
ws.send(JSON.stringify({ type: 'welcome', message: 'Connected to server' }));
|
|
26
|
+
|
|
27
|
+
// Receive messages from client
|
|
28
|
+
ws.on('message', (data) => {
|
|
29
|
+
try {
|
|
30
|
+
const message = JSON.parse(data);
|
|
31
|
+
console.log('Received:', message);
|
|
32
|
+
|
|
33
|
+
// Broadcast to all connected clients
|
|
34
|
+
wss.clients.forEach((client) => {
|
|
35
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
36
|
+
client.send(JSON.stringify({ type: 'broadcast', data: message }));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error('Invalid message:', err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Handle client disconnect
|
|
45
|
+
ws.on('close', () => {
|
|
46
|
+
console.log('Client disconnected');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Handle errors
|
|
50
|
+
ws.on('error', (error) => {
|
|
51
|
+
console.error('WebSocket error:', error);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
server.listen(3000, () => {
|
|
56
|
+
console.log('WebSocket server listening on port 3000');
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Browser Client
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
const ws = new WebSocket('ws://localhost:3000');
|
|
64
|
+
|
|
65
|
+
// Connection opened
|
|
66
|
+
ws.onopen = () => {
|
|
67
|
+
console.log('Connected to server');
|
|
68
|
+
ws.send(JSON.stringify({ type: 'greeting', name: 'John' }));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Receive messages
|
|
72
|
+
ws.onmessage = (event) => {
|
|
73
|
+
const message = JSON.parse(event.data);
|
|
74
|
+
console.log('Received:', message);
|
|
75
|
+
|
|
76
|
+
if (message.type === 'welcome') {
|
|
77
|
+
console.log(message.message);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Connection closed
|
|
82
|
+
ws.onclose = () => {
|
|
83
|
+
console.log('Disconnected from server');
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Error handling
|
|
87
|
+
ws.onerror = (error) => {
|
|
88
|
+
console.error('WebSocket error:', error);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Send message to server
|
|
92
|
+
function sendMessage(msg) {
|
|
93
|
+
if (ws.readyState === WebSocket.OPEN) {
|
|
94
|
+
ws.send(JSON.stringify({ type: 'message', text: msg }));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## With Socket.io (Higher-Level)
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm install socket.io express
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
const express = require('express');
|
|
107
|
+
const { createServer } = require('http');
|
|
108
|
+
const { Server } = require('socket.io');
|
|
109
|
+
|
|
110
|
+
const app = express();
|
|
111
|
+
const server = createServer(app);
|
|
112
|
+
const io = new Server(server, {
|
|
113
|
+
cors: { origin: '*' }
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
io.on('connection', (socket) => {
|
|
117
|
+
console.log(`User ${socket.id} connected`);
|
|
118
|
+
|
|
119
|
+
// Send to specific socket
|
|
120
|
+
socket.emit('welcome', { message: 'Welcome!' });
|
|
121
|
+
|
|
122
|
+
// Receive custom event
|
|
123
|
+
socket.on('message', (data) => {
|
|
124
|
+
console.log('Message:', data);
|
|
125
|
+
|
|
126
|
+
// Broadcast to all clients
|
|
127
|
+
io.emit('broadcast', {
|
|
128
|
+
from: socket.id,
|
|
129
|
+
text: data.text
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Receive message from specific room
|
|
134
|
+
socket.on('join-room', (room) => {
|
|
135
|
+
socket.join(room);
|
|
136
|
+
socket.to(room).emit('user-joined', { userId: socket.id });
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
socket.on('room-message', (data) => {
|
|
140
|
+
io.to(data.room).emit('new-message', {
|
|
141
|
+
from: socket.id,
|
|
142
|
+
text: data.text
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
socket.on('disconnect', () => {
|
|
147
|
+
console.log(`User ${socket.id} disconnected`);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
server.listen(3000, () => {
|
|
152
|
+
console.log('Server listening on port 3000');
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Socket.io Browser Client
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<script src="/socket.io/socket.io.js"></script>
|
|
160
|
+
<script>
|
|
161
|
+
const socket = io();
|
|
162
|
+
|
|
163
|
+
socket.on('connect', () => {
|
|
164
|
+
console.log('Connected:', socket.id);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
socket.on('welcome', (data) => {
|
|
168
|
+
console.log(data.message);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
socket.on('broadcast', (data) => {
|
|
172
|
+
console.log(`Message from ${data.from}:`, data.text);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Join room
|
|
176
|
+
socket.emit('join-room', 'general');
|
|
177
|
+
|
|
178
|
+
// Send room message
|
|
179
|
+
function sendToRoom(room, text) {
|
|
180
|
+
socket.emit('room-message', { room, text });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
socket.on('disconnect', () => {
|
|
184
|
+
console.log('Disconnected');
|
|
185
|
+
});
|
|
186
|
+
</script>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Chat Application Example
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
// Server
|
|
193
|
+
const wss = new WebSocket.Server({ server });
|
|
194
|
+
const rooms = new Map(); // roomId -> Set of users
|
|
195
|
+
|
|
196
|
+
wss.on('connection', (ws) => {
|
|
197
|
+
let currentRoom = null;
|
|
198
|
+
let username = null;
|
|
199
|
+
|
|
200
|
+
ws.on('message', (data) => {
|
|
201
|
+
const message = JSON.parse(data);
|
|
202
|
+
|
|
203
|
+
switch (message.type) {
|
|
204
|
+
case 'join':
|
|
205
|
+
currentRoom = message.room;
|
|
206
|
+
username = message.username;
|
|
207
|
+
|
|
208
|
+
if (!rooms.has(currentRoom)) {
|
|
209
|
+
rooms.set(currentRoom, new Set());
|
|
210
|
+
}
|
|
211
|
+
rooms.get(currentRoom).add(ws);
|
|
212
|
+
|
|
213
|
+
// Notify others in room
|
|
214
|
+
broadcast(currentRoom, {
|
|
215
|
+
type: 'user-joined',
|
|
216
|
+
username: username,
|
|
217
|
+
usersInRoom: rooms.get(currentRoom).size
|
|
218
|
+
});
|
|
219
|
+
break;
|
|
220
|
+
|
|
221
|
+
case 'chat':
|
|
222
|
+
broadcast(currentRoom, {
|
|
223
|
+
type: 'message',
|
|
224
|
+
username: username,
|
|
225
|
+
text: message.text,
|
|
226
|
+
timestamp: new Date().toISOString()
|
|
227
|
+
});
|
|
228
|
+
break;
|
|
229
|
+
|
|
230
|
+
case 'typing':
|
|
231
|
+
broadcast(currentRoom, {
|
|
232
|
+
type: 'user-typing',
|
|
233
|
+
username: username
|
|
234
|
+
}, ws);
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
ws.on('close', () => {
|
|
240
|
+
if (currentRoom) {
|
|
241
|
+
rooms.get(currentRoom).delete(ws);
|
|
242
|
+
broadcast(currentRoom, {
|
|
243
|
+
type: 'user-left',
|
|
244
|
+
username: username,
|
|
245
|
+
usersInRoom: rooms.get(currentRoom).size
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
function broadcast(room, message, exclude = null) {
|
|
252
|
+
const clients = rooms.get(room) || new Set();
|
|
253
|
+
const data = JSON.stringify(message);
|
|
254
|
+
|
|
255
|
+
clients.forEach((client) => {
|
|
256
|
+
if (client !== exclude && client.readyState === WebSocket.OPEN) {
|
|
257
|
+
client.send(data);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## With TypeScript
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
import WebSocket from 'ws';
|
|
267
|
+
|
|
268
|
+
interface Message {
|
|
269
|
+
type: string;
|
|
270
|
+
[key: string]: any;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const wss = new WebSocket.Server({ port: 3000 });
|
|
274
|
+
|
|
275
|
+
wss.on('connection', (ws: WebSocket) => {
|
|
276
|
+
ws.on('message', (data: string) => {
|
|
277
|
+
try {
|
|
278
|
+
const message: Message = JSON.parse(data);
|
|
279
|
+
handleMessage(ws, message);
|
|
280
|
+
} catch (err) {
|
|
281
|
+
ws.send(JSON.stringify({ error: 'Invalid JSON' }));
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
function handleMessage(ws: WebSocket, message: Message): void {
|
|
287
|
+
switch (message.type) {
|
|
288
|
+
case 'echo':
|
|
289
|
+
ws.send(JSON.stringify({ type: 'echo', data: message.data }));
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Pub/Sub Pattern
|
|
296
|
+
|
|
297
|
+
```javascript
|
|
298
|
+
const EventEmitter = require('events');
|
|
299
|
+
const pubsub = new EventEmitter();
|
|
300
|
+
|
|
301
|
+
wss.on('connection', (ws) => {
|
|
302
|
+
const subscriptions = new Set();
|
|
303
|
+
|
|
304
|
+
ws.on('message', (data) => {
|
|
305
|
+
const message = JSON.parse(data);
|
|
306
|
+
|
|
307
|
+
if (message.type === 'subscribe') {
|
|
308
|
+
subscriptions.add(message.topic);
|
|
309
|
+
|
|
310
|
+
// Subscribe to events
|
|
311
|
+
const handler = (data) => {
|
|
312
|
+
ws.send(JSON.stringify({
|
|
313
|
+
type: 'message',
|
|
314
|
+
topic: message.topic,
|
|
315
|
+
data
|
|
316
|
+
}));
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
pubsub.on(message.topic, handler);
|
|
320
|
+
|
|
321
|
+
// Store handler for unsubscribe
|
|
322
|
+
ws.handlers = ws.handlers || new Map();
|
|
323
|
+
ws.handlers.set(message.topic, handler);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (message.type === 'publish') {
|
|
327
|
+
pubsub.emit(message.topic, message.data);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
ws.on('close', () => {
|
|
332
|
+
subscriptions.forEach((topic) => {
|
|
333
|
+
const handler = ws.handlers.get(topic);
|
|
334
|
+
pubsub.off(topic, handler);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Best Practices
|
|
341
|
+
|
|
342
|
+
✅ **Handle disconnections** - Client can lose connection any time
|
|
343
|
+
✅ **Send heartbeats** - Keep connection alive with ping/pong frames
|
|
344
|
+
✅ **Validate messages** - Never trust client data
|
|
345
|
+
✅ **Use acknowledgments** - Wait for client confirmation for important messages
|
|
346
|
+
✅ **Implement reconnection** - Auto-reconnect with exponential backoff
|
|
347
|
+
✅ **Scale with Redis** - For multiple servers, use Redis pub/sub
|
|
348
|
+
✅ **Rate limiting** - Prevent spam from clients
|
|
349
|
+
|
|
350
|
+
## Scaling with Redis
|
|
351
|
+
|
|
352
|
+
```javascript
|
|
353
|
+
const redis = require('redis');
|
|
354
|
+
const { createAdapter } = require('@socket.io/redis-adapter');
|
|
355
|
+
|
|
356
|
+
const redisClient = redis.createClient();
|
|
357
|
+
const pubClient = redisClient.duplicate();
|
|
358
|
+
|
|
359
|
+
io.adapter(createAdapter(pubClient, pubClient));
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## Performance Considerations
|
|
363
|
+
|
|
364
|
+
- Binary data: Use `binaryType: 'arraybuffer'` for efficient binary transmission
|
|
365
|
+
- Message batching: Send multiple updates in one message
|
|
366
|
+
- Compression: Enable permessage-deflate in production
|
|
367
|
+
- Connection pooling: Limit max connections per IP
|
|
368
|
+
- Memory management: Clean up abandoned connections
|
|
369
|
+
|
|
370
|
+
## Common Use Cases
|
|
371
|
+
|
|
372
|
+
✅ Real-time chat applications
|
|
373
|
+
✅ Live notifications
|
|
374
|
+
✅ Collaborative editing (Figma, Google Docs style)
|
|
375
|
+
✅ Live dashboards and monitoring
|
|
376
|
+
✅ Multiplayer games
|
|
377
|
+
✅ Stock price updates
|
|
378
|
+
✅ Live video streams (metadata)
|
|
379
|
+
|
|
380
|
+
## When NOT to Use WebSockets
|
|
381
|
+
|
|
382
|
+
❌ Simple one-time requests (use HTTP instead)
|
|
383
|
+
❌ Large file transfers (use streaming APIs)
|
|
384
|
+
❌ When HTTP polling is sufficient
|
|
385
|
+
❌ Browser compatibility needed with old browsers
|
|
386
|
+
|
|
387
|
+
## Resources
|
|
388
|
+
|
|
389
|
+
- [WebSocket Standard](https://html.spec.whatwg.org/multipage/web-sockets.html)
|
|
390
|
+
- [ws Library](https://github.com/websockets/ws)
|
|
391
|
+
- [Socket.io](https://socket.io/)
|
|
392
|
+
- [Socket.io Documentation](https://socket.io/docs/)
|