apideck-express
v5.0.0
Published
Lightweight, beautiful, zero-config API playground and explorer for Express.js APIs
Maintainers
Readme
apideck-express v5.0
Lightweight, beautiful, zero-config API playground and explorer for Express.js APIs.
ApiDeck automatically inspects your Express routing stack to generate a stunning UI allowing you to browse, test, and document your API without writing manual OpenAPI YAML files.
✨ What's New in v5.0
- 💻 Multi-Language Code Generator: Generate native code snippets in JavaScript (
fetch,axios), PHP (Guzzle,cURL), and C# (HttpClient). - 📜 Request History Log: View past executions with status badges (
200 OK,404), latency metrics, and 1-click execution replay. - ⚡ Performance Load Tester: Built-in Stress Benchmarker (10, 50, 100 requests) with average latency, P95/P99 calculations, and visual latency chart.
- 📦 Postman v2.1 & OpenAPI Import/Export: 1-click Postman v2.1 Collection export + external OpenAPI / Postman spec importer.
- 🗺️ Interactive Node Visualizer: SVG canvas graph mapping API routes, feature groups, and schemas.
- 🔤 Dual Sorting: Sort collections and endpoints alphabetically (
A-Z/Z-A). - 💾 Full State Retention: Preserves parameter inputs, body text, and response results when switching endpoints.
Installation
npm install apideck-expressQuick Start
Register the middleware by passing your Express app instance:
const express = require('express');
const apideck = require('apideck-express');
const app = express();
app.use(express.json());
// ... define your routes ...
app.get('/api/users', (req, res) => {
res.json([{ id: 1, name: 'John Doe' }]);
});
// Enable ApiDeck
app.use('/apideck', apideck({
app: app, // Pass your express instance!
title: 'My Express API',
version: '1.0.0',
description: 'Explore my Node.js Express API dynamically'
}));
app.listen(3000, () => {
console.log('Server is running on http://localhost:3000');
console.log('Explore your API at http://localhost:3000/apideck');
});Now open http://localhost:3000/apideck in your browser!
Advanced: Dynamic Schema Reflection (Auto-Example Generation)
Unlike strongly typed languages, standard Node.js routing doesn't provide types for request/response bodies natively. However, ApiDeck includes a powerful introspection engine.
To have ApiDeck auto-generate Example JSON payloads and schema properties in the UI, attach a Class or Object to the .schema (or .model, .DTO) property of your route handler:
Using a Class (DTO)
class CreateUserDTO {
constructor() {
this.name = "John Doe";
this.email = "[email protected]";
this.isActive = true;
this.age = 30;
}
}
const createUser = (req, res) => {
res.status(201).json({ success: true });
};
// Attach the class to the handler
createUser.schema = CreateUserDTO;
app.post('/api/users', createUser);Using a Raw Object
const updateUser = (req, res) => res.json({ success: true });
updateUser.schema = {
properties: {
role: { type: 'string' },
permissions: { type: 'array' }
},
example: {
role: "admin",
permissions: ["read", "write"]
}
};
app.patch('/api/users/:id', updateUser);License
MIT License
