APIForge Analyzernpm
Download Package
apiforge-analyzer · v1.0.0

Zero-config API
documentation generator

Drop two lines into your Express or Next.js server. APIForge analyzes every route, generates OpenAPI specs, and publishes beautiful interactive docs — automatically.

ExpressNext.js PagesNext.js AppViteReact Router

Get started in 2 minutes

Quick Start

1

Install via npm

bash
npm install apiforge-analyzer
2

Add to your server — after all routes are registered

server.js
const APIForge = require('apiforge-analyzer')

// ↓ Call this AFTER all app.get/post/etc. are registered
APIForge.analyze(app, {
  projectName: 'My API',
  saveJson:    true,
  jsonPath:    './api-export.json',
})
3

Upload the generated JSON to APIForge

Run your server once, then drag api-export.json into the Import JSON tab.

npm · local link · direct download

Installation

Option A — npm (recommended)

bash
npm install apiforge-analyzer

Option B — Download ZIP & npm link

setup.sh
# 1. Click "Download Package" above and unzip
cd apiforge-analyzer

# 2. Build
npm install && npm run build

# 3. Global link
npm link

# 4. In your project
cd /path/to/your/project
npm link apiforge-analyzer

Requirements: Node.js ≥ 18 · npm ≥ 9 · Express 4.x or 5.x

Framework guide

Express

Call analyze() after all routes are registered but before app.listen().

server.ts
import express from 'express'
import { analyze } from 'apiforge-analyzer'

const app = express()
app.use(express.json())

// ← your routes go here
app.get('/api/users', (req, res) => res.json({ users: [] }))
app.post('/api/users', (req, res) => res.status(201).json({ created: true }))

// ← analyze after routes, before listen
await analyze(app, {
  projectName: 'My API',
  saveJson:    true,           // write api-export.json
  jsonPath:    './api-export.json',
  baseUrl:     'https://api.example.com',
})

app.listen(4000, () => console.log('🚀 Running on :4000'))

Pages Router & App Router

Next.js

Pages Router

pages/api/analyze.ts
import { analyzeNextPages } from 'apiforge-analyzer'
import type { NextApiRequest, NextApiResponse } from 'next'

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
  const routes = await analyzeNextPages({
    projectName: 'My Next.js API',
    saveJson: true,
  })
  res.json({ success: true, routes: routes.length })
}

App Router

app/api/analyze/route.ts
import { analyzeNextApp } from 'apiforge-analyzer'

export async function GET() {
  const routes = await analyzeNextApp({
    projectName: 'My API',
    nextDir: 'app',   // or 'src/app'
    saveJson: true,
  })
  return Response.json({ success: true, routes: routes.length })
}

analyze() options

API Reference

OptionTypeDefaultDescription
projectNamestringrequiredName shown in the docs
apiKeystringoptionalYour APIForge API key
uploadbooleanfalsePush routes to APIForge
saveJsonbooleanfalseWrite api-export.json locally
jsonPathstringapi-export.jsonCustom path for local JSON
apiForgeUrlstringhttp://localhost:3000APIForge server URL
baseUrlstringAPI base URL shown in docs
frameworkstringautoForce: express / nextjs-pages / nextjs-app
skipInProductionbooleantrueAuto-skip when NODE_ENV=production
runOncebooleantrueDebounce repeat calls within 5 s

Common issues

Troubleshooting

No routes found

Ensure analyze() is called AFTER all app.get/post/etc. Express lazily initializes its router — calling analyze() too early yields an empty stack.

javascript
// ✅ Correct — analyze AFTER routes
app.get('/api/users', handler)
app.post('/api/users', handler)
await analyze(app, { projectName: 'My API' })  // ← after
app.listen(3000)

// ❌ Wrong — analyze BEFORE routes
await analyze(app, { ... })
app.get('/api/users', handler)  // ← too late

Regex patterns in paths (e.g. (?=/|))

Upgrade to apiforge-analyzer v1.0.1+. The path normalizer now strips all Express regex artifacts before exporting.

bash
# Update package
npm install apiforge-analyzer@latest

Module not found after npm link

bash
cd apiforge-analyzer
npm install && npm run build && npm link

cd /your/project
npm link apiforge-analyzer
npm list apiforge-analyzer  # should show the version

APIForge Analyzer · Built for developers who ship fast