Package Exports
- postflame
- postflame/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postflame) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🔥 Postflame
Postflame is a powerful CLI tool that automatically generates Postman collections from your Hono applications with Zod schema validation. Transform your API routes into ready-to-use Postman collections in seconds!
✨ Features
- 🚀 Automatic Generation - Converts Hono routes to Postman collections instantly
- 📝 OpenAPI Support - Reads from
@hono/zod-openapiendpoints for rich documentation - 🔄 Fallback Parsing - Works even without OpenAPI by parsing routes directly
- ☁️ Direct Upload - Push collections to Postman workspace via API
- 🎯 Zod Integration - Leverages Zod schemas for request/response examples
- 📦 Multiple Content Types - Supports JSON, form-data, and URL-encoded bodies
- 🏷️ Smart Organization - Groups endpoints by tags into folders
📦 Installation
npm install -g postflameOr use with npx:
npx postflame <path-to-app.ts>🚀 Quick Start
Super Simple Usage
Just run postflame in your project directory - it will auto-detect your app file!
# Auto-detect and generate
postflame generateThat's it! Postflame will:
- 🔍 Find your app file (app.ts, index.ts, or main.ts)
- 📦 Compile TypeScript automatically
- 🔥 Generate
postman.json - ☁️ Auto-upload to Postman if
POSTMAN_API_KEYis in your.env
With Auto-Upload to Postman
Create a .env file in your project root:
POSTMAN_API_KEY=your_api_key_hereThen run:
postflame generateOr force push with the --push flag:
postflame generate --pushCustom Options
# Specify input file
postflame generate --input src/app.ts
# Custom output path
postflame generate --output my-api.json
# Short form
postflame gen -i src/app.ts -o api.json -p📖 Usage Examples
Example Hono App
import { Hono } from 'hono';
import { zValidator } from '@hono/zod-validator';
import { z } from 'zod';
const app = new Hono();
const ProductSchema = z.object({
name: z.string(),
price: z.number(),
description: z.string().optional(),
});
app.get('/products', (c) => {
return c.json({ products: [] });
});
app.post('/products', zValidator('json', ProductSchema), (c) => {
const data = c.req.valid('json');
return c.json({ success: true, product: data });
});
export { app };Generate Collection
# Just run postflame - it handles everything!
postflame generateWith OpenAPI (Recommended)
For richer documentation with examples and descriptions:
import { OpenAPIHono } from '@hono/zod-openapi';
import { z } from 'zod';
const app = new OpenAPIHono();
app.openapi(
{
method: 'post',
path: '/products',
tags: ['Products'],
request: {
body: {
content: {
'application/json': {
schema: z.object({
name: z.string().openapi({ example: 'iPhone 15' }),
price: z.number().openapi({ example: 999 }),
}),
},
},
},
},
responses: {
200: {
description: 'Product created successfully',
},
},
},
(c) => {
return c.json({ success: true });
}
);
// Important: Add the doc endpoint
app.doc('/doc', {
openapi: '3.0.0',
info: { title: 'My API', version: '1.0.0' },
});
export { app };🔧 CLI Commands & Options
Commands
postflame generate # Generate collection (default)
postflame gen # Short alias
postflame g # Even shorter!
postflame run # Alternative alias
postflame help # Show helpOptions
| Option | Short | Description | Default |
|---|---|---|---|
--input <file> |
-i |
Path to app file | Auto-detected |
--output <file> |
-o |
Output file path | postman.json |
--push |
-p |
Force upload to Postman | Auto if API key in .env |
Auto-Detection
Postflame searches for these files in order:
app.tsin root directoryindex.tsin root directorymain.tsin root directoryserver.tsin root directorysrc/app.tssrc/index.tssrc/main.tssrc/server.ts
Also checks for .js versions of these files.
🔑 Postman API Key Setup
Recommended: Use .env file
Create a .env file in your project root:
POSTMAN_API_KEY=your_api_key_herePostflame will automatically read this and upload your collection!
Alternative: Environment Variable
# Linux/Mac
export POSTMAN_API_KEY=your_key_here
# Windows (PowerShell)
$env:POSTMAN_API_KEY="your_key_here"Get Your API Key
- Go to Postman API Keys
- Click "Generate API Key"
- Copy and add to your
.envfile
🛠️ Programmatic Usage
You can also use Postflame as a library:
import { generatePostmanCollection, saveCollectionToFile } from 'postflame';
import { app } from './app';
const collection = await generatePostmanCollection(app, 'My API');
saveCollectionToFile(collection, 'output.json');📋 Requirements
- Node.js 16+
- A Hono application
- TypeScript (recommended)
🤝 Contributing
Contributions are welcome! Feel free to open issues or submit PRs.
📄 License
MIT
🔗 Links
Made with 🔥 by Tamiopia