Deployment
This guide covers building and deploying HonestJS applications.
Build & Run
Projects created with the CLI include build and start scripts:
bun run build # compile for production
bun run start # start the production serverThe application listens on the port configured by your environment (PORT env variable, defaulting to 3000).
Environment Variables
Configure these in your deployment platform:
| Variable | Purpose | Default |
|---|---|---|
PORT | Server listen port | 3000 |
NODE_ENV | Environment mode | undefined |
DATABASE_URL | Database connection string (if needed) | - |
Docker
Docker configuration is optional. To include it when scaffolding:
honestjs new my-app --dockerThis generates a Dockerfile (and optionally docker-compose.yml). If you didn't enable Docker during project creation, you can add a Dockerfile manually:
FROM oven/bun:1 AS base
WORKDIR /app
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile --production
COPY . .
RUN bun run build
EXPOSE 3000
CMD ["bun", "run", "start"]Build and run
docker build -t my-honestjs-app .
docker run -p 3000:3000 my-honestjs-appHealth Checks
Add a health endpoint to your application for load balancers and orchestrators:
import { Controller, Get, VERSION_NEUTRAL } from 'honestjs'
@Controller('health', { version: VERSION_NEUTRAL })
class HealthController {
@Get()
check() {
return { status: 'ok', timestamp: new Date().toISOString() }
}
}Using VERSION_NEUTRAL ensures the health endpoint is accessible regardless of API versioning configuration.
Platform Guides
Railway / Render / Fly.io
These platforms auto-detect Bun projects. Set the start command to bun run start and they handle the rest.
Vercel
- Connect your repository
- Set build command:
bun run build - Set output directory:
dist(if applicable) - Deploy
Cloudflare Workers
HonestJS runs on Hono, which has native Cloudflare Workers support. Export the Hono instance from your entry file:
export default honoThen configure wrangler.toml to point at your entry file.
Production Considerations
- Enable secure headers - use
@honestjs/middleware'sSecureHeadersMiddlewareor Hono's built-in secure headers - Use HTTPS - terminate TLS at your load balancer or reverse proxy
- Validate all inputs - use guards and pipes for authentication and validation
- Use structured logging - pass a custom
loggerinHonestOptionsfor production-grade log output - Set
NODE_ENV=production- some middleware and error handling adapts behavior based on this
