A complete guide to create and configure a Fastify project within a monorepo managed with pnpm workspace.
Prerequisites
Node.js (v22 or higher)
pnpm installed
Monorepo Structure
The final structure will look like this:
app-monorepo/ ├── package.json ├── pnpm-workspace.yaml ├── apps/ │ └── api/ │ ├── package.json │ ├── tsconfig.json │ ├── src/ │ │ ├── app.ts │ │ ├── server.ts │ │ ├── routes/ │ │ │ ├── root.ts │ │ │ └── users/ │ │ │ └── index.ts │ │ └── plugins/ │ │ ├── cors.ts │ │ ├── helmet.ts │ │ └── sensible.ts │ └── test/ │ ├── helper.ts │ ├── tsconfig.json │ ├── plugins/ │ │ └── sensible.test.ts │ └── routes/ │ └── example.test.ts └── tsconfig.json
Note: Separating app.ts from server.ts is an official Fastify convention.…