Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

express-to-fastify-migration

БесплатноЗапускает вложенные скриптыНе проверен

Migrate Express.js REST APIs to Fastify with automated testing, performance benchmarking, and schema generation. Use when migrating Express applications to…

timrogersот timrogers★ 30 звёзд на GitHub11 установок в других каталогах

Об этом скилле

Express to Fastify Migration

MANDATORY WORKFLOW

You MUST complete each phase IN ORDER. Do NOT proceed to the next phase until the current phase is complete. Report your progress after each phase.


Phase 1: Assessment & Baseline Capture (REQUIRED before any code changes)

Before writing ANY code, you MUST:

1.1 Document the existing codebase:

  1. Routes: List ALL Express routes in the codebase (method, path, handler)
  2. Middleware: List ALL middleware (global and route-specific)
  3. Dependencies: List ALL Express-related dependencies from package.json
  4. Custom patterns: Note any authentication, error handling, or custom middleware

1.2 Capture Express API responses (CRITICAL):

You MUST save the actual API responses BEFORE making any code changes. These are required to verify output compatibility in Phase 6.

For EACH endpoint identified in 1.1, capture the response:

# Example: save responses to files for later comparison
curl -s "http://localhost:PORT/endpoint" | jq . > /tmp/express_endpoint.json
curl -s "http://localhost:PORT/endpoint?query=test" | jq . > /tmp/express_endpoint_query.json

Save responses for:

  • Success cases (200 responses)
  • Error cases (400/404 responses)
  • Response headers (especially Cache-Control, Content-Type)

1.3 Capture Express baseline performance (CRITICAL):

You MUST benchmark the Express server BEFORE making any code changes. This baseline is required for performance comparison in Phase 6.

  1. Install autocannon: npm install autocannon --save-dev
  2. Start the Express server
  3. Run benchmarks on key endpoints and record the results:
npx autocannon -c 10 -d 10 http://localhost:PORT/endpoint
  1. Save these metrics - you will compare against them in Phase 6:
    • Requests/second
    • Average latency
    • Throughput (bytes/sec)

STOP: You MUST report your assessment findings, saved API responses, AND Express baseline metrics before proceeding to Phase 2.


Phase 2: Dependencies

Install Fastify and equivalents for EACH Express plugin identified in Phase 1.

REQUIRED plugins (ALWAYS install these):

  • fastify - Core framework
  • @fastify/helmet - Security headers (REQUIRED)
  • @fastify/rate-limit - Rate limiting (REQUIRED)

Conditional plugins (install if Express equivalent was used):

  • compression → @fastify/compress
  • cors → @fastify/cors
  • cookie-parser → @fastify/cookie
  • express-session → @fastify/session
  • body-parser → Built-in (no plugin needed)

IMPORTANT: Do NOT uninstall Express yet!

Keep Express installed until Phase 6 (Performance Verification) is complete. This allows you to run both servers simultaneously for benchmarking comparison.

STOP: Confirm all Fastify dependencies installed before Phase 3. Express stays installed for now.


Phase 3: Route Migration

For EACH route identified in Phase 1, you MUST:

  1. Convert syntax using these patterns:

    • app.get() → fastify.get()
    • req/res → request/reply
    • res.json(data) → return data
    • res.status(code).json(data) → reply.code(code); return data
    • res.header() → reply.header()
  2. Add JSON schema for validation (REQUIRED for every route):

fastify.get('/example', {
  schema: {
    querystring: {
      type: 'object',
      properties: {
        query: { type: 'string' }
      }
    },
    response: {
      200: {
        type: 'object',
        properties: {
          data: { type: 'array' }
        }
      }
    }
  }
}, async (request, reply) => {
  // handler
});
  1. Convert middleware to hooks:
    • Global middleware → fastify.addHook('onRequest', ...)
    • Route middleware → preHandler option
    • Error middleware → fastify.setErrorHandler(...)

Consult references/migration_patterns.md for detailed examples.

STOP: Confirm all routes migrated with schemas before Phase 4.


Phase 4: Server Setup

Update the server entry point:

  1. Configure Fastify with logging:
const app = Fastify({ logger: true });
  1. Register REQUIRED security plugins:
app.register(helmet);
app.register(rateLimit, { max: 100, timeWindow: '1 minute' });
  1. Register error handler:
app.setErrorHandler((error, request, reply) => {
  request.log.error(error);
  reply.status(error.statusCode || 500).send({ error: error.message });
});
  1. Update server startup to use Fastify's listen():
await app.listen({ port: PORT, host: '0.0.0.0' });

STOP: Confirm server setup complete before Phase 5.


Phase 5: Validation (REQUIRED before completion)

You MUST complete ALL of these checks:

Build & Test

  • Run npm run build - MUST succeed with no errors
  • Run npm test - ALL tests MUST pass
  • Run linting - MUST pass or only have unrelated warnings

Code Quality Verification

  • ALL routes have JSON schemas
  • Security plugins registered (`@fastify/helmet
Полный SKILL.md на GitHub

Установить express-to-fastify-migration в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

assets/package.jsonassets/server_template.jsassets/test_config.jsonreferences/migration_patterns.mdreferences/plugin_ecosystem.mdscripts/benchmark.jsscripts/compare_apis.pyscripts/schema_generator.js

FAQ

Что делает скилл express-to-fastify-migration?

Migrate Express.js REST APIs to Fastify with automated testing, performance benchmarking, and schema generation. Use when migrating Express applications to Fastify, modernizing Node.js APIs, improving API performance, or when users mention Express to Fastify migration, Fastify conversion, API modernization, or performance optimization of Express apps.

Как установить скилл express-to-fastify-migration?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл express-to-fastify-migration запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить express-to-fastify-migration с