npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

apiforge-analyzer

v1.2.1

Published

Universal API documentation generator for Express, Next.js, Vite, React Router, and Node.js

Readme

APIForge Analyzer

Universal API documentation generator for Express, Next.js, Vite, React Router, and Node.js.

Supports both ESM (import) and CommonJS (require).

📦 Installation

npm install apiforge-analyzer

🚀 Quick Start

Express (CommonJS)

const express = require('express')
const { analyze } = require('apiforge-analyzer')

const app = express()

app.get('/api/users', (req, res) => res.json({ users: [] }))
app.post('/api/users', (req, res) => res.json({ created: true }))

analyze(app, {
  projectName: 'My API',
  apiKey: process.env.APIFORGE_KEY,
  upload: true
})

app.listen(3000)

Express (ESM)

import express from 'express'
import { analyze } from 'apiforge-analyzer'

const app = express()

app.get('/api/users', (req, res) => res.json({ users: [] }))

await analyze(app, {
  projectName: 'My API',
  apiKey: process.env.APIFORGE_KEY
})

app.listen(3000)

Next.js Pages Router

// pages/api/analyze.ts
import { analyzeNextPages } from 'apiforge-analyzer'

export default async function handler(req, res) {
  await analyzeNextPages({
    projectName: 'My Next.js API',
    apiKey: process.env.APIFORGE_KEY,
    upload: true
  })
  
  res.json({ success: true })
}

Next.js App Router

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

export async function GET() {
  await analyzeNextApp({
    projectName: 'My Next.js API',
    apiKey: process.env.APIFORGE_KEY,
    upload: true
  })
  
  return Response.json({ success: true })
}

Vite

// vite-analyze.js
import { analyzeVite } from 'apiforge-analyzer'

// Analyzes proxy routes in vite.config.js
await analyzeVite({
  projectName: 'My Vite App',
  apiKey: process.env.APIFORGE_KEY,
  upload: true
})

Example Vite Config:

// vite.config.js
export default {
  server: {
    proxy: {
      '/api': 'http://localhost:3000',
      '/auth': 'http://localhost:3001'
    }
  }
}

React Router

// analyze-routes.js
import { analyzeReactRouter } from 'apiforge-analyzer'

// Analyzes routes from src/routes.tsx
await analyzeReactRouter({
  projectName: 'My React App',
  apiKey: process.env.APIFORGE_KEY,
  upload: true
})

Example Routes File:

// src/routes.tsx
import { createBrowserRouter } from 'react-router-dom'

export const router = createBrowserRouter([
  { path: '/', element: <Home /> },
  { path: '/users/:id', element: <UserDetail /> },
  { path: '/about', element: <About /> }
])

⚙️ Configuration

Options

interface AnalyzerOptions {
  // Required
  projectName: string          // Name of your project

  // Optional
  baseUrl?: string            // Base URL of your API
  apiKey?: string             // APIForge API key
  apiForgeUrl?: string        // APIForge server URL (default: http://localhost:3000)
  upload?: boolean            // Upload to APIForge (default: true if apiKey provided)
  saveJson?: boolean          // Save routes to JSON file
  jsonPath?: string           // Path for JSON file (default: api-export.json)
  framework?: string          // Force framework detection
  nextDir?: string            // Next.js directory or config file path
  skipInProduction?: boolean  // Skip in production (default: true)
}

Environment Variables

APIFORGE_KEY=your-api-key
APIFORGE_URL=http://localhost:3000  # or https://apiforge.dev
NODE_ENV=development  # Analysis skipped if production

📚 Framework Support

| Framework | Status | Import | |-----------|--------|--------| | Express | ✅ Full | analyzeExpress or analyze | | Next.js Pages | ✅ Full | analyzeNextPages | | Next.js App Router | ✅ Full | analyzeNextApp | | Vite | ✅ Full | analyzeVite | | React Router | ✅ Full | analyzeReactRouter |

📖 Examples

Export to JSON Only

import { analyze } from 'apiforge-analyzer'

await analyze(app, {
  projectName: 'My API',
  saveJson: true,
  jsonPath: './docs/api.json',
  upload: false  // Don't upload
})

Auto-Detection

// Framework is auto-detected
import { analyze } from 'apiforge-analyzer'

await analyze(app, { projectName: 'My API' })

Custom Config Paths

// Vite with custom config
await analyzeVite({
  projectName: 'My App',
  nextDir: 'vite.config.ts'  // Custom path
})

// React Router with custom routes file
await analyzeReactRouter({
  projectName: 'My App',
  nextDir: 'src/app/routes.tsx'  // Custom path
})

Skip in Production

// Automatically skips if NODE_ENV=production
await analyze(app, {
  projectName: 'My API',
  skipInProduction: true  // Default
})

🔑 Getting an API Key

  1. Sign up at APIForge
  2. Go to Dashboard → API Keys
  3. Generate a new key
  4. Set APIFORGE_KEY=your-key in .env

🛠️ Module Support

This package supports both ESM and CommonJS:

// ESM
import { analyze } from 'apiforge-analyzer'

// CommonJS
const { analyze } = require('apiforge-analyzer')

// Default import (CommonJS)
const apiforge = require('apiforge-analyzer').default

📝 What Gets Analyzed

  • ✅ Route paths
  • ✅ HTTP methods (GET, POST, PUT, DELETE, etc.)
  • ✅ Path parameters (:id, :userId)
  • ✅ Middleware names
  • ✅ Route tags/groups
  • ✅ Response codes
  • ✅ Proxy configurations (Vite)
  • ✅ Frontend routes (React Router)

🧪 Testing Locally

See NPM_LINK_TEST.md for detailed testing instructions using npm link.

🤝 Contributing

Pull requests welcome! Please see CONTRIBUTING.md.

📄 License

MIT © APIForge


Made with ❤️ by the APIForge team