pikku-deploy-express

$npx mdskill add pikkujs/pikku/pikku-deploy-express

Deploy Pikku apps with Express servers or middleware.

  • Installs @pikku/express packages for standalone or middleware use.
  • Creates PikkuExpressServer instances with custom port and hostname.
  • Triggers on imports of @pikku/express or @pikku/express-middleware.
  • Generates configuration and starts HTTP servers on port 4002.

SKILL.md

.github/skills/pikku-deploy-expressView on GitHub ↗
---
name: pikku-deploy-express
description: 'Use when deploying a Pikku app with Express. Covers PikkuExpressServer standalone and pikkuExpressMiddleware for existing Express apps.
TRIGGER when: code imports @pikku/express or @pikku/express-middleware, user mentions Express deployment, or start.ts creates a PikkuExpressServer.
DO NOT TRIGGER when: just defining functions/wirings without Express-specific code.'
---

# Pikku Express Deployment

## Standalone Server

```bash
yarn add @pikku/express
```

```typescript
import { PikkuExpressServer } from '@pikku/express'
import './.pikku/pikku-bootstrap.gen.js'
import { createConfig, createSingletonServices } from './services.js'

const config = await createConfig()
const singletonServices = await createSingletonServices(config)

const appServer = new PikkuExpressServer(
  { ...config, port: 4002, hostname: 'localhost' },
  singletonServices.logger
)
appServer.enableExitOnSigInt()
await appServer.init()
await appServer.start()
```

**Constructor:** `new PikkuExpressServer(config, logger)`

**Config extends CoreConfig with:**
- `port: number`
- `hostname: string`
- `healthCheckPath?: string`
- `limits?: Partial<Record<string, string>>`
- `content?: LocalContentConfig` (for static assets / file uploads)

**Methods:**
- `init(httpOptions?): Promise<void>` — Register middleware and routes
- `start(): Promise<void>` — Start listening
- `stop(): Promise<void>` — Graceful shutdown
- `enableExitOnSigInt(): Promise<void>` — SIGINT handler
- `enableCors(options): void` — Enable CORS
- `enableStaticAssets(): void` — Serve static files (requires `content` config)

**Property:** `app: Express` — Direct access to Express instance for custom middleware.

## Middleware (existing Express app)

```bash
yarn add @pikku/express-middleware
```

```typescript
import express from 'express'
import { pikkuExpressMiddleware } from '@pikku/express-middleware'
import './.pikku/pikku-bootstrap.gen.js'

const app = express()
app.use(pikkuExpressMiddleware({
  logger: singletonServices.logger,
  logRoutes: true,
  loadSchemas: true,
}))
```

More from pikkujs/pikku

SkillDescription
pikku-addon'Use when creating or consuming reusable function packages (addons) in Pikku. Covers wireAddon, addon(), pikkuAddonServices, pikkuAddonWireServices, addon package structure, and cross-project function sharing.
pikku-ai-agent'Use when building AI agents, chatbots, or LLM-powered assistants with Pikku. Covers pikkuAIAgent, tool registration, memory, streaming, and agent invocation.
pikku-ai-vercel'Use when setting up AI agent execution with the Vercel AI SDK in a Pikku app. Covers VercelAIAgentRunner for streaming and non-streaming AI agent steps.
pikku-ai-voice'Use when adding voice input (speech-to-text) or voice output (text-to-speech) to AI agents in a Pikku app. Covers voiceInput/voiceOutput middleware hooks and STT/TTS service interfaces.
pikku-auth-js'Use when integrating Auth.js (NextAuth) with a Pikku app. Covers createAuthHandler, createAuthRoutes, and Auth.js configuration.
pikku-aws'Use when setting up AWS services (S3, SQS, Secrets Manager) in a Pikku app. Covers S3Content for file storage, SQSQueueService for queues, and AWSSecrets for secret management.
pikku-backblaze'Use when setting up Backblaze B2 file storage in a Pikku app. Covers B2Content for file uploads, downloads, and signed URLs.
pikku-cli'Use when building CLI commands with Pikku. Covers wireCLI, pikkuCLICommand, subcommands, options, parameters, custom renderers, and nested command groups.
pikku-concepts'Foundational guide to Pikku framework concepts. Use this skill when working with any Pikku codebase, starting a new Pikku project, or migrating a backend to Pikku. Covers the core mental model, function types, project structure, code generation, testing, and how Pikku maps to traditional backend patterns.
pikku-config'Use when managing secrets, environment variables, config, or OAuth2 credentials in a Pikku app. Covers wireSecret, wireVariable, wireOAuth2Credential, and typed config access.