Express → Fastify
medium2x faster throughput, built-in validation with JSON Schema, TypeScript-first. Plugin system > middleware chain.
Estimated: 4-12h · 6 steps
Progress0%
Step 1: Install Fastify
npm install fastify @fastify/cors @fastify/helmet && npm uninstall express
Step 2: Rewrite server entry
Replace app = express() with Fastify({ logger: true }). Register plugins instead of app.use().
import Fastify from 'fastify'
const app = Fastify({ logger: true })Step 3: Convert routes
app.get('/path', (req, res) => ...) → app.get('/path', async (request, reply) => ...). Note: reply not res.
Step 4: Add validation schemas
Replace express-validator/joi with JSON Schema on route level. Fastify validates automatically.
Step 5: Replace middleware
body-parser → built-in. cors → @fastify/cors. helmet → @fastify/helmet. multer → @fastify/multipart.
Step 6: Test
✓ All API endpoints return correct responses. Benchmark shows throughput improvement.