1. Import Fastify
Fastify is a fast, low-overhead Node framework imported as a default factory.
import Fastify from "fastify";Typorithm · medium
Step 1 of 8 · intro card
Web Frameworks
Fastify is a fast, low-overhead Node framework: async handlers return the payload directly, logging is built in, a plugin system adds features, and JSON-schema validation and serialization make it quick. It is built for performance and developer experience.
Fastify is a high-performance Node framework focused on low overhead. You create an app with the Fastify() factory, optionally enabling its built-in logger.
Handlers are async functions that receive the request and simply return a value; Fastify serializes that return into the response, so there is no explicit res.json call.
Features are added through a first-class plugin system, and JSON-schema definitions drive both request validation and ultra-fast response serialization — the core reasons Fastify is quick.
Fastify() creates the app; logger: true enables logging.
Async handlers return the payload directly.
Plugins and JSON-schema serialization make it fast.
import Fastify from "fastify";
const app = Fastify({ logger: true });
app.get("/users/:id", async (req) => {
return { id: req.params.id };
});
await app.listen({ port: 3000 });Connect each part of the code to the concept before you type.
Fastify is a fast, low-overhead Node framework imported as a default factory.
import Fastify from "fastify";Passing logger: true turns on Fastify's built-in structured logger out of the box.
const app = Fastify({ logger: true });Fastify handlers are async functions that take the request and return the payload.
app.get("/users/:id", async (req) => {Returning an object directly lets Fastify serialize it as the JSON response.
return { id: req.params.id };app.listen returns a promise, so it is awaited after all plugins are registered.
await app.listen({ port: 3000 });Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.