pikku-deploy-fastify
$
npx mdskill add pikkujs/pikku/pikku-deploy-fastifyDeploy Pikku applications using Fastify, supporting both standalone servers and existing plugin integration.
- Handles setting up and running Pikku apps within a Fastify framework environment.
- Integrates with the Fastify HTTP server and Pikku's core configuration/service layers.
- Triggers when Fastify-related imports are detected or when deployment context is established.
- Provides direct methods to initialize, start, and manage the application lifecycle.
SKILL.md
.github/skills/pikku-deploy-fastifyView on GitHub ↗
---
name: pikku-deploy-fastify
description: 'Use when deploying a Pikku app with Fastify. Covers PikkuFastifyServer standalone and pikkuFastifyPlugin for existing Fastify apps.
TRIGGER when: code imports @pikku/fastify or @pikku/fastify-plugin, user mentions Fastify deployment, or start.ts creates a PikkuFastifyServer.
DO NOT TRIGGER when: just defining functions/wirings without Fastify-specific code.'
---
# Pikku Fastify Deployment
## Standalone Server
```bash
yarn add @pikku/fastify
```
```typescript
import { PikkuFastifyServer } from '@pikku/fastify'
import './.pikku/pikku-bootstrap.gen.js'
import { createConfig, createSingletonServices } from './services.js'
const config = await createConfig()
const singletonServices = await createSingletonServices(config)
const appServer = new PikkuFastifyServer(
{ ...config, hostname: 'localhost', port: 4002 },
singletonServices.logger
)
appServer.enableExitOnSigInt()
await appServer.init()
await appServer.start()
```
**Constructor:** `new PikkuFastifyServer(config, logger)`
**Config extends CoreConfig with:** `port`, `hostname`, `healthCheckPath?`
**Methods:** `init(httpOptions?)`, `start()`, `stop()`, `enableExitOnSigInt()`
**Property:** `app: FastifyInstance` — Direct access to Fastify instance.
## Plugin (existing Fastify app)
```bash
yarn add @pikku/fastify-plugin
```
```typescript
import Fastify from 'fastify'
import pikkuFastifyPlugin from '@pikku/fastify-plugin'
import './.pikku/pikku-bootstrap.gen.js'
const app = Fastify()
app.register(pikkuFastifyPlugin, {
pikku: {
logger: singletonServices.logger,
logRoutes: true,
loadSchemas: true,
},
})
```