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,217 @@
|
|
|
1
|
+
# Error Tracking & Reporting
|
|
2
|
+
|
|
3
|
+
Catch and track errors in production applications.
|
|
4
|
+
|
|
5
|
+
## Sentry Integration
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import * as Sentry from "@sentry/node";
|
|
9
|
+
import { NodeProfilingIntegration } from "@sentry/profiling-node";
|
|
10
|
+
|
|
11
|
+
Sentry.init({
|
|
12
|
+
dsn: process.env.SENTRY_DSN,
|
|
13
|
+
integrations: [
|
|
14
|
+
new Sentry.Integrations.Http({ tracing: true }),
|
|
15
|
+
new NodeProfilingIntegration()
|
|
16
|
+
],
|
|
17
|
+
tracesSampleRate: 1.0,
|
|
18
|
+
profilesSampleRate: 1.0
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Express middleware
|
|
22
|
+
app.use(Sentry.Handlers.requestHandler());
|
|
23
|
+
|
|
24
|
+
// Your routes...
|
|
25
|
+
|
|
26
|
+
app.use(Sentry.Handlers.errorHandler());
|
|
27
|
+
|
|
28
|
+
// Manual error reporting
|
|
29
|
+
try {
|
|
30
|
+
await someAsyncOperation();
|
|
31
|
+
} catch (error) {
|
|
32
|
+
Sentry.captureException(error, {
|
|
33
|
+
tags: {
|
|
34
|
+
section: 'critical'
|
|
35
|
+
},
|
|
36
|
+
extra: {
|
|
37
|
+
userId: req.user.id,
|
|
38
|
+
orderId: req.body.orderId
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Rollbar Integration
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import Rollbar from 'rollbar';
|
|
48
|
+
|
|
49
|
+
const rollbar = new Rollbar({
|
|
50
|
+
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
|
|
51
|
+
environment: process.env.NODE_ENV
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
app.use((err: any, req: any, res: any, next: any) => {
|
|
55
|
+
rollbar.error(err, { request: req });
|
|
56
|
+
res.status(500).json({ error: 'Internal Server Error' });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Manual logging
|
|
60
|
+
rollbar.info('User login', { userId: user.id });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Custom Error Tracking
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import * as fs from 'fs/promises';
|
|
67
|
+
import * as path from 'path';
|
|
68
|
+
|
|
69
|
+
interface ErrorLog {
|
|
70
|
+
timestamp: Date;
|
|
71
|
+
message: string;
|
|
72
|
+
stack?: string;
|
|
73
|
+
context?: Record<string, any>;
|
|
74
|
+
severity: 'error' | 'warning' | 'info';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
class ErrorTracker {
|
|
78
|
+
private logDir = './logs';
|
|
79
|
+
|
|
80
|
+
async logError(error: Error, context?: any) {
|
|
81
|
+
const log: ErrorLog = {
|
|
82
|
+
timestamp: new Date(),
|
|
83
|
+
message: error.message,
|
|
84
|
+
stack: error.stack,
|
|
85
|
+
context,
|
|
86
|
+
severity: 'error'
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Write to file
|
|
90
|
+
const filename = `${new Date().toISOString().split('T')[0]}.json`;
|
|
91
|
+
const filepath = path.join(this.logDir, filename);
|
|
92
|
+
|
|
93
|
+
const existing = await this.readLogs(filepath);
|
|
94
|
+
existing.push(log);
|
|
95
|
+
|
|
96
|
+
await fs.writeFile(filepath, JSON.stringify(existing, null, 2));
|
|
97
|
+
|
|
98
|
+
// Alert if critical
|
|
99
|
+
if (context?.critical) {
|
|
100
|
+
await this.alertAdmins(log);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private async readLogs(filepath: string): Promise<ErrorLog[]> {
|
|
105
|
+
try {
|
|
106
|
+
const content = await fs.readFile(filepath, 'utf-8');
|
|
107
|
+
return JSON.parse(content);
|
|
108
|
+
} catch {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private async alertAdmins(log: ErrorLog) {
|
|
114
|
+
// Send alert via Slack, email, etc.
|
|
115
|
+
console.error('CRITICAL ERROR:', log.message);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const errorTracker = new ErrorTracker();
|
|
120
|
+
|
|
121
|
+
app.use((err: any, req: any, res: any, next: any) => {
|
|
122
|
+
errorTracker.logError(err, {
|
|
123
|
+
url: req.url,
|
|
124
|
+
method: req.method,
|
|
125
|
+
userId: req.user?.id,
|
|
126
|
+
critical: err.statusCode >= 500
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
res.status(500).json({ error: 'Internal Server Error' });
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Source Maps
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// webpack.config.js
|
|
137
|
+
module.exports = {
|
|
138
|
+
mode: 'production',
|
|
139
|
+
devtool: 'hidden-source-map',
|
|
140
|
+
// ...
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Upload source maps to Sentry
|
|
144
|
+
import { exec } from 'child_process';
|
|
145
|
+
import { promisify } from 'util';
|
|
146
|
+
|
|
147
|
+
const execAsync = promisify(exec);
|
|
148
|
+
|
|
149
|
+
async function uploadSourceMaps() {
|
|
150
|
+
const version = process.env.RELEASE || 'dev';
|
|
151
|
+
|
|
152
|
+
await execAsync(`
|
|
153
|
+
sentry-cli releases files upload-sourcemaps \
|
|
154
|
+
--org myorg \
|
|
155
|
+
--project myproject \
|
|
156
|
+
--release ${version} \
|
|
157
|
+
./dist
|
|
158
|
+
`);
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Error Boundaries (React)
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import React, { ReactNode } from 'react';
|
|
166
|
+
import * as Sentry from "@sentry/react";
|
|
167
|
+
|
|
168
|
+
interface Props {
|
|
169
|
+
children: ReactNode;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface State {
|
|
173
|
+
hasError: boolean;
|
|
174
|
+
error?: Error;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
class ErrorBoundary extends React.Component<Props, State> {
|
|
178
|
+
constructor(props: Props) {
|
|
179
|
+
super(props);
|
|
180
|
+
this.state = { hasError: false };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
static getDerivedStateFromError(error: Error) {
|
|
184
|
+
return { hasError: true, error };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
componentDidCatch(error: Error, errorInfo: any) {
|
|
188
|
+
Sentry.captureException(error, { contexts: { react: errorInfo } });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
render() {
|
|
192
|
+
if (this.state.hasError) {
|
|
193
|
+
return <h1>Something went wrong</h1>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return this.props.children;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export default Sentry.withErrorBoundary(ErrorBoundary, {
|
|
201
|
+
fallback: <h1>An error occurred</h1>
|
|
202
|
+
});
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Best Practices
|
|
206
|
+
|
|
207
|
+
✅ **Capture context** - Include user, request, state info
|
|
208
|
+
✅ **Alert on critical** - Real-time notifications for severe errors
|
|
209
|
+
✅ **Source maps** - Map minified code to original
|
|
210
|
+
✅ **Group errors** - Identify duplicate issues
|
|
211
|
+
✅ **Monitor trends** - Track error rates over time
|
|
212
|
+
|
|
213
|
+
## Resources
|
|
214
|
+
|
|
215
|
+
- [Sentry Documentation](https://docs.sentry.io/)
|
|
216
|
+
- [Rollbar](https://rollbar.com/)
|
|
217
|
+
- [Bugsnag](https://www.bugsnag.com/)
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Node.js Streams
|
|
2
|
+
|
|
3
|
+
Efficient data processing with streams.
|
|
4
|
+
|
|
5
|
+
## Stream Types
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Readable, Writable, Transform, Duplex } from 'stream';
|
|
9
|
+
|
|
10
|
+
// Readable stream
|
|
11
|
+
const readable = new Readable({
|
|
12
|
+
read() {
|
|
13
|
+
this.push('data');
|
|
14
|
+
this.push(null); // Signal end
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Writable stream
|
|
19
|
+
const writable = new Writable({
|
|
20
|
+
write(chunk, encoding, callback) {
|
|
21
|
+
console.log('Received:', chunk);
|
|
22
|
+
callback();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Transform stream
|
|
27
|
+
const transform = new Transform({
|
|
28
|
+
transform(chunk, encoding, callback) {
|
|
29
|
+
const transformed = chunk.toString().toUpperCase();
|
|
30
|
+
this.push(transformed);
|
|
31
|
+
callback();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Duplex (both readable and writable)
|
|
36
|
+
const duplex = new Duplex({
|
|
37
|
+
read() {},
|
|
38
|
+
write(chunk, encoding, callback) {
|
|
39
|
+
console.log('Written:', chunk);
|
|
40
|
+
callback();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Piping
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import fs from 'fs';
|
|
49
|
+
import zlib from 'zlib';
|
|
50
|
+
|
|
51
|
+
// Simple pipe
|
|
52
|
+
fs.createReadStream('input.txt')
|
|
53
|
+
.pipe(fs.createWriteStream('output.txt'));
|
|
54
|
+
|
|
55
|
+
// Multiple transforms
|
|
56
|
+
fs.createReadStream('large-file.txt')
|
|
57
|
+
.pipe(transform1)
|
|
58
|
+
.pipe(transform2)
|
|
59
|
+
.pipe(fs.createWriteStream('output.txt'));
|
|
60
|
+
|
|
61
|
+
// Compression
|
|
62
|
+
fs.createReadStream('file.txt')
|
|
63
|
+
.pipe(zlib.createGzip())
|
|
64
|
+
.pipe(fs.createWriteStream('file.txt.gz'));
|
|
65
|
+
|
|
66
|
+
// Handle errors
|
|
67
|
+
fs.createReadStream('input.txt')
|
|
68
|
+
.on('error', (error) => console.error('Read error:', error))
|
|
69
|
+
.pipe(fs.createWriteStream('output.txt'))
|
|
70
|
+
.on('error', (error) => console.error('Write error:', error));
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Processing Large Files
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
function processLargeCSV(filePath: string) {
|
|
77
|
+
const { createReadStream } = require('fs');
|
|
78
|
+
const { createInterface } = require('readline');
|
|
79
|
+
|
|
80
|
+
const stream = createReadStream(filePath);
|
|
81
|
+
const rl = createInterface({
|
|
82
|
+
input: stream,
|
|
83
|
+
crlfDelay: Infinity
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
let lineCount = 0;
|
|
87
|
+
|
|
88
|
+
rl.on('line', (line) => {
|
|
89
|
+
lineCount++;
|
|
90
|
+
const record = JSON.parse(line);
|
|
91
|
+
|
|
92
|
+
// Process record
|
|
93
|
+
processRecord(record);
|
|
94
|
+
|
|
95
|
+
// Report progress every 1000 lines
|
|
96
|
+
if (lineCount % 1000 === 0) {
|
|
97
|
+
console.log(`Processed ${lineCount} lines`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
rl.on('close', () => {
|
|
102
|
+
console.log(`Total lines: ${lineCount}`);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Custom Transform
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const { Transform } = require('stream');
|
|
111
|
+
|
|
112
|
+
class UpperCaseTransform extends Transform {
|
|
113
|
+
transform(chunk: any, encoding: string, callback: Function) {
|
|
114
|
+
const transformed = chunk.toString().toUpperCase();
|
|
115
|
+
this.push(transformed);
|
|
116
|
+
callback();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Usage
|
|
121
|
+
readable
|
|
122
|
+
.pipe(new UpperCaseTransform())
|
|
123
|
+
.pipe(writable);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Memory Efficient Processing
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
// Bad: Load entire file into memory
|
|
130
|
+
const data = fs.readFileSync('large-file.txt', 'utf-8');
|
|
131
|
+
const lines = data.split('\n');
|
|
132
|
+
lines.forEach(processLine);
|
|
133
|
+
|
|
134
|
+
// Good: Stream processing
|
|
135
|
+
fs.createReadStream('large-file.txt')
|
|
136
|
+
.pipe(split())
|
|
137
|
+
.on('data', processLine);
|
|
138
|
+
|
|
139
|
+
// Bad: Buffer accumulation
|
|
140
|
+
let buffer = '';
|
|
141
|
+
stream.on('data', (chunk) => {
|
|
142
|
+
buffer += chunk; // Can cause memory issues
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Good: Backpressure handling
|
|
146
|
+
stream.on('data', (chunk) => {
|
|
147
|
+
if (!destination.write(chunk)) {
|
|
148
|
+
stream.pause();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
destination.on('drain', () => {
|
|
153
|
+
stream.resume();
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Best Practices
|
|
158
|
+
|
|
159
|
+
✅ **Handle backpressure** - Pause when buffer full
|
|
160
|
+
✅ **Error handling** - Listen for error events
|
|
161
|
+
✅ **Piping** - Use pipe over manual event handlers
|
|
162
|
+
✅ **Memory limits** - Monitor heap usage
|
|
163
|
+
✅ **Cleanup** - Close streams properly
|
|
164
|
+
|
|
165
|
+
## Resources
|
|
166
|
+
|
|
167
|
+
- [Node.js Stream API](https://nodejs.org/api/stream.html)
|
|
168
|
+
- [Stream Handbook](https://github.com/substack/stream-handbook)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Production-Ready Skill Implementation
|
|
2
|
+
|
|
3
|
+
## Setup & Installation
|
|
4
|
+
|
|
5
|
+
Detailed installation and configuration steps for the technology.
|
|
6
|
+
|
|
7
|
+
## Core Concepts
|
|
8
|
+
|
|
9
|
+
Fundamental patterns and approaches.
|
|
10
|
+
|
|
11
|
+
## Implementation Examples
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// Real production code examples
|
|
15
|
+
// with error handling and best practices
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Advanced Patterns
|
|
19
|
+
|
|
20
|
+
Complex scenarios and optimization techniques.
|
|
21
|
+
|
|
22
|
+
## Performance Optimization
|
|
23
|
+
|
|
24
|
+
Tips for maximizing efficiency and speed.
|
|
25
|
+
|
|
26
|
+
## Security Considerations
|
|
27
|
+
|
|
28
|
+
Security best practices specific to this technology.
|
|
29
|
+
|
|
30
|
+
## Testing
|
|
31
|
+
|
|
32
|
+
How to properly test this feature.
|
|
33
|
+
|
|
34
|
+
## Monitoring & Debugging
|
|
35
|
+
|
|
36
|
+
Tools and techniques for production support.
|
|
37
|
+
|
|
38
|
+
## Best Practices
|
|
39
|
+
|
|
40
|
+
✅ Key recommendations
|
|
41
|
+
✅ Common pitfalls to avoid
|
|
42
|
+
✅ Performance considerations
|
|
43
|
+
✅ Security measures
|
|
44
|
+
✅ Production readiness
|
|
45
|
+
|
|
46
|
+
## Resources
|
|
47
|
+
|
|
48
|
+
- Official documentation
|
|
49
|
+
- Community guides
|
|
50
|
+
- Performance benchmarks
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Dependency Injection Patterns
|
|
2
|
+
|
|
3
|
+
Managing dependencies and composing complex objects.
|
|
4
|
+
|
|
5
|
+
## Constructor Injection
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// Define interfaces
|
|
9
|
+
interface Database {
|
|
10
|
+
query(sql: string): Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Logger {
|
|
14
|
+
log(message: string): void;
|
|
15
|
+
error(message: string): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Service with injected dependencies
|
|
19
|
+
class UserService {
|
|
20
|
+
constructor(
|
|
21
|
+
private db: Database,
|
|
22
|
+
private logger: Logger
|
|
23
|
+
) {}
|
|
24
|
+
|
|
25
|
+
async getUser(id: string) {
|
|
26
|
+
this.logger.log(`Fetching user ${id}`);
|
|
27
|
+
const user = await this.db.query(`SELECT * FROM users WHERE id = ${id}`);
|
|
28
|
+
return user;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Concrete implementations
|
|
33
|
+
class PostgresDatabase implements Database {
|
|
34
|
+
async query(sql: string) {
|
|
35
|
+
// PostgreSQL logic
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class ConsoleLogger implements Logger {
|
|
40
|
+
log(message: string) {
|
|
41
|
+
console.log(`[LOG] ${message}`);
|
|
42
|
+
}
|
|
43
|
+
error(message: string) {
|
|
44
|
+
console.error(`[ERROR] ${message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Usage
|
|
49
|
+
const db = new PostgresDatabase();
|
|
50
|
+
const logger = new ConsoleLogger();
|
|
51
|
+
const userService = new UserService(db, logger);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Service Container
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
class Container {
|
|
58
|
+
private services = new Map<string, any>();
|
|
59
|
+
private singletons = new Map<string, any>();
|
|
60
|
+
|
|
61
|
+
register(name: string, factory: () => any) {
|
|
62
|
+
this.services.set(name, factory);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
singleton(name: string, factory: () => any) {
|
|
66
|
+
const instance = factory();
|
|
67
|
+
this.singletons.set(name, instance);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get(name: string): any {
|
|
71
|
+
// Return singleton if exists
|
|
72
|
+
if (this.singletons.has(name)) {
|
|
73
|
+
return this.singletons.get(name);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Create instance from factory
|
|
77
|
+
const factory = this.services.get(name);
|
|
78
|
+
if (!factory) {
|
|
79
|
+
throw new Error(`Service ${name} not registered`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return factory();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Setup
|
|
87
|
+
const container = new Container();
|
|
88
|
+
|
|
89
|
+
container.singleton('db', () => new PostgresDatabase());
|
|
90
|
+
container.singleton('logger', () => new ConsoleLogger());
|
|
91
|
+
|
|
92
|
+
container.register('userService', () =>
|
|
93
|
+
new UserService(container.get('db'), container.get('logger'))
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
container.register('postService', () =>
|
|
97
|
+
new PostService(container.get('db'), container.get('logger'))
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
// Usage
|
|
101
|
+
const userService = container.get('userService');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Factory Pattern
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
interface PaymentProvider {
|
|
108
|
+
charge(amount: number): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
class StripeProvider implements PaymentProvider {
|
|
112
|
+
async charge(amount: number) {
|
|
113
|
+
// Stripe implementation
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
class PayPalProvider implements PaymentProvider {
|
|
118
|
+
async charge(amount: number) {
|
|
119
|
+
// PayPal implementation
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
class PaymentProviderFactory {
|
|
124
|
+
static create(provider: 'stripe' | 'paypal'): PaymentProvider {
|
|
125
|
+
switch (provider) {
|
|
126
|
+
case 'stripe':
|
|
127
|
+
return new StripeProvider();
|
|
128
|
+
case 'paypal':
|
|
129
|
+
return new PayPalProvider();
|
|
130
|
+
default:
|
|
131
|
+
throw new Error(`Unknown provider: ${provider}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Usage
|
|
137
|
+
const provider = PaymentProviderFactory.create('stripe');
|
|
138
|
+
await provider.charge(100);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Async DI
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
class Container {
|
|
145
|
+
private services = new Map<string, () => Promise<any>>();
|
|
146
|
+
|
|
147
|
+
async get(name: string): Promise<any> {
|
|
148
|
+
const factory = this.services.get(name);
|
|
149
|
+
if (!factory) {
|
|
150
|
+
throw new Error(`Service ${name} not found`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return factory();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
register(name: string, factory: () => Promise<any>) {
|
|
157
|
+
this.services.set(name, factory);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const container = new Container();
|
|
162
|
+
|
|
163
|
+
container.register('db', async () => {
|
|
164
|
+
const db = new Database();
|
|
165
|
+
await db.connect();
|
|
166
|
+
return db;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Usage
|
|
170
|
+
const db = await container.get('db');
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Decorators
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import 'reflect-metadata';
|
|
177
|
+
import { Inject } from 'tsyringe';
|
|
178
|
+
import { Container } from 'tsyringe';
|
|
179
|
+
|
|
180
|
+
@injectable()
|
|
181
|
+
class Logger {
|
|
182
|
+
log(msg: string) {
|
|
183
|
+
console.log(msg);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@injectable()
|
|
188
|
+
class UserService {
|
|
189
|
+
constructor(@Inject('logger') private logger: Logger) {}
|
|
190
|
+
|
|
191
|
+
getUser(id: string) {
|
|
192
|
+
this.logger.log(`Getting user ${id}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Setup
|
|
197
|
+
const container = new Container();
|
|
198
|
+
container.registerSingleton('logger', Logger);
|
|
199
|
+
container.register('userService', UserService);
|
|
200
|
+
|
|
201
|
+
// Usage
|
|
202
|
+
const userService = container.resolve(UserService);
|
|
203
|
+
userService.getUser('123');
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Best Practices
|
|
207
|
+
|
|
208
|
+
✅ **Program to interfaces** - Not implementations
|
|
209
|
+
✅ **Single responsibility** - Each service has one job
|
|
210
|
+
✅ **Dependency inversion** - Depend on abstractions
|
|
211
|
+
✅ **Use containers** - For complex applications
|
|
212
|
+
✅ **Testing** - Mock dependencies easily
|
|
213
|
+
|
|
214
|
+
## Resources
|
|
215
|
+
|
|
216
|
+
- [Dependency Injection](https://martinfowler.com/articles/injection.html)
|
|
217
|
+
- [tsyringe](https://github.com/Microsoft/tsyringe)
|
|
218
|
+
- [InversifyJS](https://inversify.io/)
|