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,414 @@
|
|
|
1
|
+
# .NET / C#
|
|
2
|
+
|
|
3
|
+
Modern server-side development with strong typing, high performance, and excellent tooling.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
dotnet new webapi -n MyApi
|
|
9
|
+
cd MyApi
|
|
10
|
+
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
|
|
11
|
+
dotnet add package Serilog.AspNetCore
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## ASP.NET Core Project Structure
|
|
15
|
+
|
|
16
|
+
```csharp
|
|
17
|
+
// Program.cs - Entry point and DI configuration
|
|
18
|
+
using Microsoft.AspNetCore.Builder;
|
|
19
|
+
using Microsoft.Extensions.DependencyInjection;
|
|
20
|
+
|
|
21
|
+
var builder = WebApplication.CreateBuilder(args);
|
|
22
|
+
|
|
23
|
+
// Add services to DI container
|
|
24
|
+
builder.Services.AddControllers();
|
|
25
|
+
builder.Services.AddScoped<IUserService, UserService>();
|
|
26
|
+
builder.Services.AddScoped<IEmailService, EmailService>();
|
|
27
|
+
builder.Services.AddDbContext<AppDbContext>(options =>
|
|
28
|
+
options.UseSqlServer(builder.Configuration.GetConnectionString("Default")));
|
|
29
|
+
builder.Services.AddCors(options =>
|
|
30
|
+
{
|
|
31
|
+
options.AddPolicy("AllowAll", p => p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
var app = builder.Build();
|
|
35
|
+
|
|
36
|
+
// Configure middleware pipeline
|
|
37
|
+
app.UseHttpsRedirection();
|
|
38
|
+
app.UseCors("AllowAll");
|
|
39
|
+
app.UseAuthorization();
|
|
40
|
+
app.MapControllers();
|
|
41
|
+
|
|
42
|
+
app.Run();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Controllers and Dependency Injection
|
|
46
|
+
|
|
47
|
+
```csharp
|
|
48
|
+
using Microsoft.AspNetCore.Mvc;
|
|
49
|
+
|
|
50
|
+
[ApiController]
|
|
51
|
+
[Route("api/[controller]")]
|
|
52
|
+
public class UsersController : ControllerBase
|
|
53
|
+
{
|
|
54
|
+
private readonly IUserService _userService;
|
|
55
|
+
private readonly ILogger<UsersController> _logger;
|
|
56
|
+
|
|
57
|
+
// Constructor injection - dependencies resolved automatically
|
|
58
|
+
public UsersController(IUserService userService, ILogger<UsersController> logger)
|
|
59
|
+
{
|
|
60
|
+
_userService = userService;
|
|
61
|
+
_logger = logger;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[HttpGet("{id}")]
|
|
65
|
+
public async Task<ActionResult<UserDto>> GetUser(int id)
|
|
66
|
+
{
|
|
67
|
+
_logger.LogInformation("Fetching user {UserId}", id);
|
|
68
|
+
|
|
69
|
+
var user = await _userService.GetUserAsync(id);
|
|
70
|
+
if (user == null)
|
|
71
|
+
return NotFound(new { message = "User not found" });
|
|
72
|
+
|
|
73
|
+
return Ok(user);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[HttpPost]
|
|
77
|
+
[ProducesResponseType(StatusCodes.Status201Created)]
|
|
78
|
+
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
79
|
+
public async Task<ActionResult<UserDto>> CreateUser([FromBody] CreateUserRequest request)
|
|
80
|
+
{
|
|
81
|
+
_logger.LogInformation("Creating user with email {Email}", request.Email);
|
|
82
|
+
|
|
83
|
+
try
|
|
84
|
+
{
|
|
85
|
+
var user = await _userService.CreateUserAsync(request);
|
|
86
|
+
return CreatedAtAction(nameof(GetUser), new { id = user.Id }, user);
|
|
87
|
+
}
|
|
88
|
+
catch (InvalidOperationException ex)
|
|
89
|
+
{
|
|
90
|
+
return BadRequest(new { message = ex.Message });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[HttpPut("{id}")]
|
|
95
|
+
public async Task<IActionResult> UpdateUser(int id, [FromBody] UpdateUserRequest request)
|
|
96
|
+
{
|
|
97
|
+
var updated = await _userService.UpdateUserAsync(id, request);
|
|
98
|
+
if (!updated)
|
|
99
|
+
return NotFound();
|
|
100
|
+
|
|
101
|
+
return NoContent();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[HttpDelete("{id}")]
|
|
105
|
+
public async Task<IActionResult> DeleteUser(int id)
|
|
106
|
+
{
|
|
107
|
+
var deleted = await _userService.DeleteUserAsync(id);
|
|
108
|
+
if (!deleted)
|
|
109
|
+
return NotFound();
|
|
110
|
+
|
|
111
|
+
return NoContent();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Entity Framework Core (ORM)
|
|
117
|
+
|
|
118
|
+
```csharp
|
|
119
|
+
using Microsoft.EntityFrameworkCore;
|
|
120
|
+
|
|
121
|
+
// Entity models with relationships
|
|
122
|
+
public class User
|
|
123
|
+
{
|
|
124
|
+
public int Id { get; set; }
|
|
125
|
+
[Required]
|
|
126
|
+
[EmailAddress]
|
|
127
|
+
public string Email { get; set; } = string.Empty;
|
|
128
|
+
|
|
129
|
+
public string Name { get; set; } = string.Empty;
|
|
130
|
+
public string PasswordHash { get; set; } = string.Empty;
|
|
131
|
+
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
132
|
+
public DateTime? LastLogin { get; set; }
|
|
133
|
+
|
|
134
|
+
// Navigation property
|
|
135
|
+
public ICollection<Post> Posts { get; set; } = new List<Post>();
|
|
136
|
+
public ICollection<Comment> Comments { get; set; } = new List<Comment>();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public class Post
|
|
140
|
+
{
|
|
141
|
+
public int Id { get; set; }
|
|
142
|
+
public string Title { get; set; } = string.Empty;
|
|
143
|
+
public string Content { get; set; } = string.Empty;
|
|
144
|
+
public bool Published { get; set; }
|
|
145
|
+
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
146
|
+
|
|
147
|
+
public int UserId { get; set; }
|
|
148
|
+
public User User { get; set; } = null!;
|
|
149
|
+
|
|
150
|
+
public ICollection<Comment> Comments { get; set; } = new List<Comment>();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public class Comment
|
|
154
|
+
{
|
|
155
|
+
public int Id { get; set; }
|
|
156
|
+
public string Content { get; set; } = string.Empty;
|
|
157
|
+
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
158
|
+
|
|
159
|
+
public int UserId { get; set; }
|
|
160
|
+
public User User { get; set; } = null!;
|
|
161
|
+
|
|
162
|
+
public int PostId { get; set; }
|
|
163
|
+
public Post Post { get; set; } = null!;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// DbContext with fluent configuration
|
|
167
|
+
public class AppDbContext : DbContext
|
|
168
|
+
{
|
|
169
|
+
public DbSet<User> Users { get; set; }
|
|
170
|
+
public DbSet<Post> Posts { get; set; }
|
|
171
|
+
public DbSet<Comment> Comments { get; set; }
|
|
172
|
+
|
|
173
|
+
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
|
174
|
+
|
|
175
|
+
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
176
|
+
{
|
|
177
|
+
// User configuration
|
|
178
|
+
modelBuilder.Entity<User>()
|
|
179
|
+
.HasIndex(u => u.Email)
|
|
180
|
+
.IsUnique();
|
|
181
|
+
|
|
182
|
+
modelBuilder.Entity<User>()
|
|
183
|
+
.HasMany(u => u.Posts)
|
|
184
|
+
.WithOne(p => p.User)
|
|
185
|
+
.HasForeignKey(p => p.UserId)
|
|
186
|
+
.OnDelete(DeleteBehavior.Cascade);
|
|
187
|
+
|
|
188
|
+
// Post configuration
|
|
189
|
+
modelBuilder.Entity<Post>()
|
|
190
|
+
.HasIndex(p => new { p.UserId, p.Published });
|
|
191
|
+
|
|
192
|
+
modelBuilder.Entity<Post>()
|
|
193
|
+
.HasMany(p => p.Comments)
|
|
194
|
+
.WithOne(c => c.Post)
|
|
195
|
+
.HasForeignKey(c => c.PostId)
|
|
196
|
+
.OnDelete(DeleteBehavior.Cascade);
|
|
197
|
+
|
|
198
|
+
// Comment configuration
|
|
199
|
+
modelBuilder.Entity<Comment>()
|
|
200
|
+
.HasIndex(c => c.CreatedAt);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Service layer using EF Core
|
|
205
|
+
public interface IUserService
|
|
206
|
+
{
|
|
207
|
+
Task<User?> GetUserAsync(int id);
|
|
208
|
+
Task<User?> GetUserWithPostsAsync(int id);
|
|
209
|
+
Task<List<User>> SearchUsersAsync(string email);
|
|
210
|
+
Task<User> CreateUserAsync(CreateUserRequest request);
|
|
211
|
+
Task<bool> UpdateUserAsync(int id, UpdateUserRequest request);
|
|
212
|
+
Task<bool> DeleteUserAsync(int id);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public class UserService : IUserService
|
|
216
|
+
{
|
|
217
|
+
private readonly AppDbContext _context;
|
|
218
|
+
|
|
219
|
+
public UserService(AppDbContext context)
|
|
220
|
+
{
|
|
221
|
+
_context = context;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public async Task<User?> GetUserAsync(int id)
|
|
225
|
+
{
|
|
226
|
+
return await _context.Users.FindAsync(id);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
public async Task<User?> GetUserWithPostsAsync(int id)
|
|
230
|
+
{
|
|
231
|
+
return await _context.Users
|
|
232
|
+
.Include(u => u.Posts)
|
|
233
|
+
.ThenInclude(p => p.Comments)
|
|
234
|
+
.Include(u => u.Comments)
|
|
235
|
+
.FirstOrDefaultAsync(u => u.Id == id);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
public async Task<List<User>> SearchUsersAsync(string email)
|
|
239
|
+
{
|
|
240
|
+
return await _context.Users
|
|
241
|
+
.Where(u => u.Email.Contains(email))
|
|
242
|
+
.OrderByDescending(u => u.CreatedAt)
|
|
243
|
+
.ToListAsync();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
public async Task<User> CreateUserAsync(CreateUserRequest request)
|
|
247
|
+
{
|
|
248
|
+
// Check if user already exists
|
|
249
|
+
var existing = await _context.Users.FirstOrDefaultAsync(u => u.Email == request.Email);
|
|
250
|
+
if (existing != null)
|
|
251
|
+
throw new InvalidOperationException("User with this email already exists");
|
|
252
|
+
|
|
253
|
+
var user = new User
|
|
254
|
+
{
|
|
255
|
+
Email = request.Email,
|
|
256
|
+
Name = request.Name,
|
|
257
|
+
PasswordHash = BCrypt.Net.BCrypt.HashPassword(request.Password)
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
_context.Users.Add(user);
|
|
261
|
+
await _context.SaveChangesAsync();
|
|
262
|
+
return user;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
public async Task<bool> UpdateUserAsync(int id, UpdateUserRequest request)
|
|
266
|
+
{
|
|
267
|
+
var user = await _context.Users.FindAsync(id);
|
|
268
|
+
if (user == null)
|
|
269
|
+
return false;
|
|
270
|
+
|
|
271
|
+
user.Name = request.Name ?? user.Name;
|
|
272
|
+
user.Email = request.Email ?? user.Email;
|
|
273
|
+
|
|
274
|
+
await _context.SaveChangesAsync();
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
public async Task<bool> DeleteUserAsync(int id)
|
|
279
|
+
{
|
|
280
|
+
var user = await _context.Users.FindAsync(id);
|
|
281
|
+
if (user == null)
|
|
282
|
+
return false;
|
|
283
|
+
|
|
284
|
+
_context.Users.Remove(user);
|
|
285
|
+
await _context.SaveChangesAsync();
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Request/Response DTOs with Validation
|
|
292
|
+
|
|
293
|
+
```csharp
|
|
294
|
+
using System.ComponentModel.DataAnnotations;
|
|
295
|
+
|
|
296
|
+
public class CreateUserRequest
|
|
297
|
+
{
|
|
298
|
+
[Required(ErrorMessage = "Email is required")]
|
|
299
|
+
[EmailAddress(ErrorMessage = "Invalid email format")]
|
|
300
|
+
[StringLength(100)]
|
|
301
|
+
public string Email { get; set; } = string.Empty;
|
|
302
|
+
|
|
303
|
+
[Required]
|
|
304
|
+
[StringLength(100, MinimumLength = 3)]
|
|
305
|
+
public string Name { get; set; } = string.Empty;
|
|
306
|
+
|
|
307
|
+
[Required]
|
|
308
|
+
[StringLength(100, MinimumLength = 8)]
|
|
309
|
+
public string Password { get; set; } = string.Empty;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
public class UpdateUserRequest
|
|
313
|
+
{
|
|
314
|
+
[StringLength(100)]
|
|
315
|
+
public string? Name { get; set; }
|
|
316
|
+
|
|
317
|
+
[EmailAddress]
|
|
318
|
+
public string? Email { get; set; }
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public class UserDto
|
|
322
|
+
{
|
|
323
|
+
public int Id { get; set; }
|
|
324
|
+
public string Email { get; set; } = string.Empty;
|
|
325
|
+
public string Name { get; set; } = string.Empty;
|
|
326
|
+
public DateTime CreatedAt { get; set; }
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Global Error Handling
|
|
331
|
+
|
|
332
|
+
```csharp
|
|
333
|
+
public class ExceptionHandlingMiddleware
|
|
334
|
+
{
|
|
335
|
+
private readonly RequestDelegate _next;
|
|
336
|
+
private readonly ILogger<ExceptionHandlingMiddleware> _logger;
|
|
337
|
+
|
|
338
|
+
public ExceptionHandlingMiddleware(RequestDelegate next, ILogger<ExceptionHandlingMiddleware> logger)
|
|
339
|
+
{
|
|
340
|
+
_next = next;
|
|
341
|
+
_logger = logger;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
public async Task InvokeAsync(HttpContext context)
|
|
345
|
+
{
|
|
346
|
+
try
|
|
347
|
+
{
|
|
348
|
+
await _next(context);
|
|
349
|
+
}
|
|
350
|
+
catch (Exception ex)
|
|
351
|
+
{
|
|
352
|
+
_logger.LogError(ex, "Unhandled exception occurred");
|
|
353
|
+
context.Response.ContentType = "application/json";
|
|
354
|
+
context.Response.StatusCode = ex switch
|
|
355
|
+
{
|
|
356
|
+
NotFoundException => StatusCodes.Status404NotFound,
|
|
357
|
+
ValidationException => StatusCodes.Status400BadRequest,
|
|
358
|
+
UnauthorizedAccessException => StatusCodes.Status401Unauthorized,
|
|
359
|
+
_ => StatusCodes.Status500InternalServerError
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
var response = new { message = ex.Message, type = ex.GetType().Name };
|
|
363
|
+
await context.Response.WriteAsJsonAsync(response);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Register in Program.cs
|
|
369
|
+
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Database Migrations
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Create migration
|
|
376
|
+
dotnet ef migrations add InitialCreate
|
|
377
|
+
|
|
378
|
+
# Apply migrations to database
|
|
379
|
+
dotnet ef database update
|
|
380
|
+
|
|
381
|
+
# Revert to previous migration
|
|
382
|
+
dotnet ef migrations remove
|
|
383
|
+
|
|
384
|
+
# List pending migrations
|
|
385
|
+
dotnet ef migrations list
|
|
386
|
+
|
|
387
|
+
# Generate SQL script
|
|
388
|
+
dotnet ef migrations script
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## Best Practices
|
|
392
|
+
|
|
393
|
+
✅ **Use async/await** - All I/O operations must be async
|
|
394
|
+
✅ **Constructor injection** - Never use new() for dependencies
|
|
395
|
+
✅ **Validation** - Use DataAnnotations or FluentValidation
|
|
396
|
+
✅ **Logging** - Structured logging with correlation IDs
|
|
397
|
+
✅ **Error handling** - Custom exceptions, middleware for global handling
|
|
398
|
+
✅ **Connection pooling** - Enabled by default, monitor pool size
|
|
399
|
+
✅ **Entity validation** - Validate in service layer, not controller
|
|
400
|
+
✅ **Migrations** - Always track schema changes with EF migrations
|
|
401
|
+
|
|
402
|
+
## Performance Tips
|
|
403
|
+
|
|
404
|
+
- Use `.AsNoTracking()` for read-only queries
|
|
405
|
+
- Project queries with `.Select()` instead of loading full entities
|
|
406
|
+
- Enable query caching with Redis
|
|
407
|
+
- Use `DbContextPool` for high-throughput scenarios
|
|
408
|
+
- Monitor N+1 queries with `eager loading` (Include/ThenInclude)
|
|
409
|
+
|
|
410
|
+
## Resources
|
|
411
|
+
|
|
412
|
+
- [ASP.NET Core Docs](https://docs.microsoft.com/aspnet/core/)
|
|
413
|
+
- [Entity Framework Core](https://learn.microsoft.com/ef/core/)
|
|
414
|
+
- [C# Language Guide](https://docs.microsoft.com/dotnet/csharp/)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Express.js
|
|
2
|
+
|
|
3
|
+
Minimalist, unopinionated Node.js web framework for building APIs and web applications.
|
|
4
|
+
|
|
5
|
+
## Basic Setup
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
const express = require('express');
|
|
9
|
+
const app = express();
|
|
10
|
+
|
|
11
|
+
// Middleware
|
|
12
|
+
app.use(express.json()); // Parse JSON requests
|
|
13
|
+
app.use(express.static('public')); // Serve static files
|
|
14
|
+
app.use((req, res, next) => {
|
|
15
|
+
console.log(`${req.method} ${req.path}`);
|
|
16
|
+
next();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Routes
|
|
20
|
+
app.get('/users', (req, res) => {
|
|
21
|
+
res.json({ users: [] });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
app.post('/users', (req, res) => {
|
|
25
|
+
const { name } = req.body;
|
|
26
|
+
res.status(201).json({ id: 1, name });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
app.listen(3000, () => console.log('Server running on :3000'));
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Middleware & Routing
|
|
33
|
+
|
|
34
|
+
### Middleware Chain
|
|
35
|
+
```javascript
|
|
36
|
+
// Execute in order
|
|
37
|
+
app.use(cors());
|
|
38
|
+
app.use(morgan('dev'));
|
|
39
|
+
app.use(express.json());
|
|
40
|
+
app.use(authenticateToken);
|
|
41
|
+
app.use('/api', apiRoutes);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Router Pattern
|
|
45
|
+
```javascript
|
|
46
|
+
const router = express.Router();
|
|
47
|
+
|
|
48
|
+
router.get('/:id', (req, res) => {
|
|
49
|
+
const { id } = req.params;
|
|
50
|
+
res.json({ id });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
router.post('/', (req, res) => {
|
|
54
|
+
res.status(201).json({ id: 1, ...req.body });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
module.exports = router;
|
|
58
|
+
|
|
59
|
+
// Use in app
|
|
60
|
+
app.use('/users', require('./routes/users'));
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Request/Response Handling
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
// Request - access data
|
|
67
|
+
app.post('/users', (req, res) => {
|
|
68
|
+
const { name } = req.body; // Parse JSON
|
|
69
|
+
const { page } = req.query; // Query params
|
|
70
|
+
const { id } = req.params; // Route params
|
|
71
|
+
const token = req.get('authorization'); // Headers
|
|
72
|
+
|
|
73
|
+
// Response
|
|
74
|
+
res.status(201)
|
|
75
|
+
.set('Content-Type', 'application/json')
|
|
76
|
+
.json({ id: 1, name });
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Error Handling
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
// Try-catch in async routes
|
|
84
|
+
app.get('/users/:id', async (req, res, next) => {
|
|
85
|
+
try {
|
|
86
|
+
const user = await db.user.findById(req.params.id);
|
|
87
|
+
if (!user) return res.status(404).json({ error: 'Not found' });
|
|
88
|
+
res.json(user);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
next(err); // Pass to error handler
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Error handling middleware (must be last)
|
|
95
|
+
app.use((err, req, res, next) => {
|
|
96
|
+
console.error(err);
|
|
97
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Useful Middleware
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
const express = require('express');
|
|
105
|
+
const cors = require('cors');
|
|
106
|
+
const morgan = require('morgan');
|
|
107
|
+
const helmet = require('helmet');
|
|
108
|
+
|
|
109
|
+
app.use(helmet()); // Security headers
|
|
110
|
+
app.use(cors()); // Cross-origin requests
|
|
111
|
+
app.use(morgan('dev')); // Request logging
|
|
112
|
+
app.use(express.json()); // Parse JSON
|
|
113
|
+
app.use(express.urlencoded({ extended: true })); // Form data
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Best Practices
|
|
117
|
+
|
|
118
|
+
1. **Structure**: Separate routes, controllers, services, models
|
|
119
|
+
2. **Validation**: Validate request data before processing
|
|
120
|
+
3. **Error Handling**: Handle errors consistently
|
|
121
|
+
4. **Logging**: Log important events for debugging
|
|
122
|
+
5. **Security**: Use helmet, validate input, sanitize data
|
|
123
|
+
6. **Performance**: Use async/await, cache where appropriate
|
|
124
|
+
7. **Testing**: Write unit and integration tests
|
|
125
|
+
|
|
126
|
+
## Resources
|
|
127
|
+
|
|
128
|
+
- [Express Official Docs](https://expressjs.com/)
|
|
129
|
+
- [RESTful API Design](https://restfulapi.net/)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Fastify
|
|
2
|
+
|
|
3
|
+
Fast and low-overhead Node.js web framework for building APIs with built-in JSON schema validation.
|
|
4
|
+
|
|
5
|
+
## Basic Setup
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
const fastify = require('fastify')({ logger: true });
|
|
9
|
+
|
|
10
|
+
fastify.get('/', async (request, reply) => {
|
|
11
|
+
return { hello: 'world' };
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
fastify.listen({ port: 3000 }, (err, address) => {
|
|
15
|
+
if (err) throw err;
|
|
16
|
+
console.log(`Server listening at ${address}`);
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Schemas & Validation
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
const schema = {
|
|
24
|
+
body: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
required: ['name', 'email'],
|
|
27
|
+
properties: {
|
|
28
|
+
name: { type: 'string' },
|
|
29
|
+
email: { type: 'string', format: 'email' }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
response: {
|
|
33
|
+
200: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
id: { type: 'number' },
|
|
37
|
+
name: { type: 'string' }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
fastify.post('/users', { schema }, async (request, reply) => {
|
|
44
|
+
// Data is validated, typed, and serialized efficiently
|
|
45
|
+
const user = await db.user.create(request.body);
|
|
46
|
+
reply.status(201).send(user);
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Plugins & Hooks
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
// Register plugin
|
|
54
|
+
fastify.register(require('@fastify/cors'));
|
|
55
|
+
fastify.register(require('@fastify/jwt'), { secret: 'secret' });
|
|
56
|
+
|
|
57
|
+
// Pre-handler hook
|
|
58
|
+
fastify.addHook('preHandler', async (request, reply) => {
|
|
59
|
+
await request.jwtVerify();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Route-level hook
|
|
63
|
+
fastify.post('/protected', {
|
|
64
|
+
onRequest: [fastify.authenticate]
|
|
65
|
+
}, async (request, reply) => {
|
|
66
|
+
return { user: request.user };
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Error Handling
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
fastify.setErrorHandler((error, request, reply) => {
|
|
74
|
+
if (error.validation) {
|
|
75
|
+
reply.status(400).send({
|
|
76
|
+
statusCode: 400,
|
|
77
|
+
error: 'Bad Request',
|
|
78
|
+
message: error.message
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
reply.status(500).send({ statusCode: 500, error: 'Internal Server Error' });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Performance
|
|
87
|
+
|
|
88
|
+
- Serializes responses using schema
|
|
89
|
+
- Efficient JSON parsing
|
|
90
|
+
- Built-in compression and caching
|
|
91
|
+
- Zero-copy response generation
|
|
92
|
+
|
|
93
|
+
## Best Practices
|
|
94
|
+
|
|
95
|
+
1. Always define schemas for validation
|
|
96
|
+
2. Use TypeScript for type safety
|
|
97
|
+
3. Leverage plugins for common functionality
|
|
98
|
+
4. Implement proper error handling
|
|
99
|
+
5. Monitor performance metrics
|
|
100
|
+
|
|
101
|
+
## Resources
|
|
102
|
+
|
|
103
|
+
- [Fastify Documentation](https://www.fastify.io/)
|
|
104
|
+
- [JSON Schema](https://json-schema.org/)
|