{"_id":"@bytedocs/hono","_rev":"2-7c8133379687d1b47e0b4696a89219e4","name":"@bytedocs/hono","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@bytedocs/hono","version":"1.0.0","keywords":["hono","documentation","api","swagger","openapi","bytedocs","auto-documentation","api-doc","rest-api","nodejs","typescript","openai","ai-assistant"],"author":{"name":"ByteDocs Contributors"},"license":"MIT","_id":"@bytedocs/hono@1.0.0","maintainers":[{"name":"aibnuhibban","email":"abd.ibnuhibban@gmail.com"}],"homepage":"https://github.com/idnexacloud/bytedocs-hono#readme","bugs":{"url":"https://github.com/idnexacloud/bytedocs-hono/issues"},"dist":{"shasum":"6f978f218c6e5e2d599efe961f8716f3c91b0d23","tarball":"https://registry.npmjs.org/@bytedocs/hono/-/hono-1.0.0.tgz","fileCount":55,"integrity":"sha512-JawJjpUOM+l0shV9uNBPcG4gUQCjLxam+PXYCrVPkGX85kxrrn2sCT7TmugNmQmW801HvyZ1kykigl1PFo6y2Q==","signatures":[{"sig":"MEUCIQDBuvI6zVKj9I1nYVmbE1zoZ6T23U5Ut7n5685E3ZjXYAIgH4KrnCQ8xO4Rkw+SlsI3hzf/OE+LgLQdWAj5r2AccSs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":540897},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16.0.0"},"gitHead":"f3063380f19a977953364ce873faf81502025745","scripts":{"dev":"tsc --watch","test":"jest","build":"tsc && npm run copy-templates","example":"cd examples/basic && npm install && npm run dev","example:ai":"cd examples/with-ai && npm install && npm run dev","example:auth":"cd examples/with-auth && npm install && npm run dev","example:basic":"cd examples/basic && npm install && npm run dev","copy-templates":"cp -r src/ui/templates dist/ui/","prepublishOnly":"npm run build"},"_npmUser":{"name":"aibnuhibban","email":"abd.ibnuhibban@gmail.com"},"repository":{"url":"git+https://github.com/idnexacloud/bytedocs-hono.git","type":"git"},"_npmVersion":"10.7.0","description":"Alternative to Swagger with better design, auto-detection, and AI integration","directories":{},"_nodeVersion":"20.15.1","dependencies":{"dotenv":"^16.4.5","js-yaml":"^4.1.0","@babel/types":"^7.23.6","@babel/parser":"^7.23.6","@babel/traverse":"^7.23.6"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^4.0.0","ts-node":"^10.9.2","typescript":"^5.3.3","@types/node":"^20.10.0","@types/js-yaml":"^4.0.9"},"peerDependencies":{"hono":"^3.0.0 || ^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hono_1.0.0_1762153562417_0.31223541333056404","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bytedocs/hono","version":"1.0.1","description":"Alternative to Swagger with better design, auto-detection, and AI integration","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc && npm run copy-templates","copy-templates":"cp -r src/ui/templates dist/ui/","dev":"tsc --watch","test":"jest","prepublishOnly":"npm run build","example":"cd examples/basic && npm install && npm run dev","example:basic":"cd examples/basic && npm install && npm run dev","example:auth":"cd examples/with-auth && npm install && npm run dev","example:ai":"cd examples/with-ai && npm install && npm run dev"},"keywords":["hono","documentation","api","swagger","openapi","bytedocs","auto-documentation","api-doc","rest-api","nodejs","typescript","openai","ai-assistant"],"author":{"name":"ByteDocs Contributors"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/idnexacloud/bytedocs-hono.git"},"homepage":"https://github.com/idnexacloud/bytedocs-hono#readme","bugs":{"url":"https://github.com/idnexacloud/bytedocs-hono/issues"},"peerDependencies":{"hono":"^3.0.0 || ^4.0.0"},"dependencies":{"@babel/parser":"^7.23.6","@babel/traverse":"^7.23.6","@babel/types":"^7.23.6","dotenv":"^16.4.5","js-yaml":"^4.1.0"},"devDependencies":{"@types/js-yaml":"^4.0.9","@types/node":"^20.10.0","hono":"^4.0.0","ts-node":"^10.9.2","typescript":"^5.3.3"},"engines":{"node":">=16.0.0"},"_id":"@bytedocs/hono@1.0.1","gitHead":"417a9add1357e727ed936a204808f451587a8308","_nodeVersion":"20.15.1","_npmVersion":"10.7.0","dist":{"integrity":"sha512-hIlpjUXxFJPJAfjCBTuCdcVpp4i2DvqnXfgcI6q8YCCtlwTINaD6YirPrqUA1AAAV0X+INjv9oM9aiBZ+J6wKQ==","shasum":"0f5a6cc989ca8f230b9469d8d8437c061ff863da","tarball":"https://registry.npmjs.org/@bytedocs/hono/-/hono-1.0.1.tgz","fileCount":55,"unpackedSize":540897,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDTtVHVqpvW1PbTQ8EsL8wWH1ps26a0ZAeH6gvoowEhigIgEY46dgRa2obqMvPAPMQeORMlCs6uuE/ofCYg4pMTu8I="}]},"_npmUser":{"name":"aibnuhibban","email":"abd.ibnuhibban@gmail.com"},"directories":{},"maintainers":[{"name":"aibnuhibban","email":"abd.ibnuhibban@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hono_1.0.1_1762279390392_0.5259589748564348"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-03T07:06:02.267Z","modified":"2025-11-04T18:03:10.834Z","1.0.0":"2025-11-03T07:06:02.664Z","1.0.1":"2025-11-04T18:03:10.610Z"},"bugs":{"url":"https://github.com/idnexacloud/bytedocs-hono/issues"},"author":{"name":"ByteDocs Contributors"},"license":"MIT","homepage":"https://github.com/idnexacloud/bytedocs-hono#readme","keywords":["hono","documentation","api","swagger","openapi","bytedocs","auto-documentation","api-doc","rest-api","nodejs","typescript","openai","ai-assistant"],"repository":{"type":"git","url":"git+https://github.com/idnexacloud/bytedocs-hono.git"},"description":"Alternative to Swagger with better design, auto-detection, and AI integration","maintainers":[{"name":"aibnuhibban","email":"abd.ibnuhibban@gmail.com"}],"readme":"# ByteDocs for Hono\n\n[![npm version](https://img.shields.io/badge/npm-%3E%3D18-blue.svg)](https://nodejs.org/)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![Documentation](https://img.shields.io/badge/docs-bytedocs-blue.svg)](https://github.com/aibnuhibban/bytedocs)\n\n**ByteDocs** is a modern alternative to Swagger with better design, auto-detection, and AI integration for Hono applications. It automatically generates beautiful API documentation from your routes with zero configuration required.\n\n## Features\n\n- 🚀 **Auto Route Detection** - Automatically discovers routes, parameters, and data structures from your Hono app\n- 🎨 **Beautiful Modern UI** - Clean, responsive interface with dark mode support\n- 🤖 **AI Integration** - Built-in AI assistant (OpenAI, Gemini, Claude, OpenRouter) to help users understand your API\n- 📱 **Mobile Responsive** - Works perfectly on all device sizes\n- 🔍 **Interactive Testing** - Try out endpoints directly from the documentation\n- 📊 **OpenAPI Compatible** - Exports standard OpenAPI 3.0.3 specification in JSON and YAML formats\n- 🔐 **Built-in Authentication** - Support for Basic Auth, API Key, Bearer Token, and Session authentication\n- ⚡ **Zero Configuration** - Works out of the box with sensible defaults\n- 🌍 **Environment Config** - Full `.env` file support with validation\n- 📝 **JSDoc Support** - Extracts documentation from JSDoc comments\n\n## Quick Start\n\n### 1. Install ByteDocs\n\n```bash\nnpm install @bytedocs/hono\n```\n\n### 2. Add One Line to Your Code\n\n```typescript\nimport { Hono } from 'hono';\nimport { setupByteDocs } from '@bytedocs/hono';\n\nconst app = new Hono();\n\n// Your API routes\napp.get('/api/users', (c) => {\n  return c.json({ users: [] });\n});\n\napp.post('/api/users', async (c) => {\n  const body = await c.req.json();\n  return c.json({ id: 1, ...body }, 201);\n});\n\n// Setup ByteDocs - that's it!\nsetupByteDocs(app, {\n  title: 'My API',\n  version: '1.0.0',\n  description: 'Auto-generated API documentation',\n  docsPath: '/docs',\n  autoDetect: true,\n});\n\nexport default app;\n```\n\n### 3. Visit Your Documentation\n\nOpen http://localhost:3000/docs and enjoy your auto-generated API documentation!\n\n## API Endpoints\n\nOnce installed, ByteDocs provides these endpoints:\n\n- `GET /docs` - Main documentation interface with beautiful UI\n- `GET /docs/api-data.json` - Raw documentation data\n- `GET /docs/openapi.json` - OpenAPI 3.0.3 specification (JSON format)\n- `GET /docs/openapi.yaml` - OpenAPI 3.0.3 specification (YAML format)\n- `POST /docs/chat` - AI chat endpoint (if AI is enabled)\n- `GET /docs/login` - Login page (if session auth enabled)\n- `POST /docs/login` - Login handler (if session auth enabled)\n- `POST /docs/logout` - Logout handler (if session auth enabled)\n\n## Configuration\n\n### Basic Configuration\n\n```typescript\nsetupByteDocs(app, {\n  title: 'My API Documentation',\n  version: '1.0.0',\n  description: 'Comprehensive API for my application',\n  docsPath: '/docs',\n  autoDetect: true,\n\n  baseURLs: [\n    { name: 'Production', url: 'https://api.myapp.com' },\n    { name: 'Staging', url: 'https://staging-api.myapp.com' },\n    { name: 'Local', url: 'http://localhost:3000' },\n  ],\n});\n```\n\n### AI Integration\n\nEnable AI assistance for your API documentation:\n\n```typescript\nsetupByteDocs(app, {\n  title: 'My API',\n  version: '1.0.0',\n  aiConfig: {\n    enabled: true,\n    provider: 'openai', // openai, gemini, claude, openrouter\n    apiKey: process.env.OPENAI_API_KEY,\n    features: {\n      chatEnabled: true,\n      docGenerationEnabled: false,\n      model: 'gpt-4o-mini',\n      maxTokens: 1000,\n      temperature: 0.7,\n    },\n  },\n});\n```\n\n**Supported AI Providers:**\n\n#### OpenAI\n```typescript\naiConfig: {\n  enabled: true,\n  provider: 'openai',\n  apiKey: process.env.OPENAI_API_KEY,\n  features: {\n    model: 'gpt-4o-mini', // or gpt-4, gpt-3.5-turbo\n  },\n}\n```\n\n#### Google Gemini\n```typescript\naiConfig: {\n  enabled: true,\n  provider: 'gemini',\n  apiKey: process.env.GEMINI_API_KEY,\n  features: {\n    model: 'gemini-1.5-flash', // or gemini-1.5-pro\n  },\n}\n```\n\n#### Anthropic Claude\n```typescript\naiConfig: {\n  enabled: true,\n  provider: 'claude',\n  apiKey: process.env.ANTHROPIC_API_KEY,\n  features: {\n    model: 'claude-3-sonnet-20240229',\n  },\n}\n```\n\n#### OpenRouter\n```typescript\naiConfig: {\n  enabled: true,\n  provider: 'openrouter',\n  apiKey: process.env.OPENROUTER_API_KEY,\n  features: {\n    model: 'openai/gpt-4o-mini', // Any OpenRouter model\n  },\n}\n```\n\n### Authentication\n\nProtect your documentation with built-in authentication:\n\n```typescript\nsetupByteDocs(app, {\n  title: 'My API',\n  version: '1.0.0',\n  authConfig: {\n    enabled: true,\n    type: 'session', // basic, api_key, bearer, session\n    password: 'your-secret-password',\n\n    // Session-specific settings\n    sessionExpire: 1440, // minutes\n    ipBanEnabled: true,\n    ipBanMaxAttempts: 5,\n    ipBanDuration: 60, // minutes\n    adminWhitelistIPs: ['127.0.0.1', '::1'],\n  },\n});\n```\n\n**Authentication Types:**\n- `basic` - HTTP Basic Authentication\n- `api_key` - API Key authentication via custom header\n- `bearer` - Bearer token authentication\n- `session` - Session-based authentication with login page\n\n### Environment Configuration\n\nCreate a `.env` file for easy configuration:\n\n```bash\n# Basic Settings\nBYTEDOCS_TITLE=\"My API Documentation\"\nBYTEDOCS_VERSION=\"1.0.0\"\nBYTEDOCS_DESCRIPTION=\"Comprehensive API for my application\"\nBYTEDOCS_DOCS_PATH=\"/docs\"\nBYTEDOCS_AUTO_DETECT=true\n\n# Multiple Environment URLs\nBYTEDOCS_PRODUCTION_URL=\"https://api.myapp.com\"\nBYTEDOCS_STAGING_URL=\"https://staging-api.myapp.com\"\nBYTEDOCS_LOCAL_URL=\"http://localhost:3000\"\n\n# Authentication\nBYTEDOCS_AUTH_ENABLED=true\nBYTEDOCS_AUTH_TYPE=session\nBYTEDOCS_AUTH_PASSWORD=your-secret-password\nBYTEDOCS_AUTH_SESSION_EXPIRE=1440\nBYTEDOCS_AUTH_IP_BAN_ENABLED=true\nBYTEDOCS_AUTH_IP_BAN_MAX_ATTEMPTS=5\nBYTEDOCS_AUTH_IP_BAN_DURATION=60\nBYTEDOCS_AUTH_ADMIN_WHITELIST_IPS=127.0.0.1,::1\n\n# AI Configuration\nBYTEDOCS_AI_ENABLED=true\nBYTEDOCS_AI_PROVIDER=openai\nBYTEDOCS_AI_API_KEY=sk-your-openai-key\nBYTEDOCS_AI_MODEL=gpt-4o-mini\nBYTEDOCS_AI_MAX_TOKENS=1000\nBYTEDOCS_AI_TEMPERATURE=0.7\n```\n\nThen load it in your code:\n```typescript\nimport { loadConfigFromEnv, validateConfig } from '@bytedocs/hono';\n\nconst config = loadConfigFromEnv();\n\n// Validate configuration\nconst validation = validateConfig(config);\nif (!validation.valid) {\n  console.error('Configuration errors:', validation.errors);\n  process.exit(1);\n}\n\nsetupByteDocs(app, config);\n```\n\n## JSDoc Annotations\n\nEnhance your documentation with JSDoc comments:\n\n```typescript\n/**\n * Get user by ID\n * @summary Retrieve a specific user\n * @tag Users\n * @param id path string true \"User ID to retrieve\"\n * @response 200 {object} User \"User object\"\n * @response 404 {object} Error \"User not found\"\n */\napp.get('/api/users/:id', (c) => {\n  const id = c.req.param('id');\n  const user = getUserById(id);\n\n  if (user) {\n    return c.json(user);\n  } else {\n    return c.json({ error: 'User not found' }, 404);\n  }\n});\n\n/**\n * Create a new user\n * @summary Create user\n * @tag Users\n * @description Creates a new user with the provided information\n * @response 201 {object} User \"Created user\"\n */\napp.post('/api/users', async (c) => {\n  const body = await c.req.json();\n  const user = createUser(body);\n  return c.json(user, 201);\n});\n```\n\n## Advanced Usage\n\n### Manual Route Registration\n\n```typescript\nimport { ByteDocs } from '@bytedocs/hono';\n\nconst docs = new ByteDocs({\n  title: 'My API',\n  version: '1.0.0',\n});\n\n// Manually add route information\ndocs.addRoute({\n  method: 'GET',\n  path: '/api/custom-endpoint',\n  summary: 'Custom endpoint',\n  description: 'This is a manually registered endpoint',\n  parameters: [\n    {\n      name: 'id',\n      in: 'path',\n      schema: { type: 'integer' },\n      required: true,\n      description: 'Record ID',\n    },\n  ],\n  handler: () => {},\n});\n\n// Generate documentation\ndocs.generate();\n```\n\n### Export OpenAPI Specifications\n\n```typescript\n// Get OpenAPI JSON\nconst openAPIJSON = docs.getOpenAPISpec();\n\n// Get OpenAPI YAML\nimport * as yaml from 'js-yaml';\nconst openAPIYAML = yaml.dump(openAPIJSON);\n\n// Save to file\nimport { writeFileSync } from 'fs';\nwriteFileSync('openapi.yaml', openAPIYAML);\n```\n\n## Hono-Specific Features\n\nByteDocs for Hono leverages Hono's features:\n\n### Built-in Cookie Support\nHono has built-in cookie utilities, so no additional middleware is needed.\n\n### Context-Based Responses\nUses Hono's Context API for consistent response handling:\n```typescript\nreturn c.json({ data }, 200);\nreturn c.text('Hello', 200);\nreturn c.html('<h1>Hello</h1>');\n```\n\n### Request Body Parsing\nHono automatically detects request body type:\n```typescript\nconst body = await c.req.json(); // JSON\nconst formData = await c.req.formData(); // Form data\nconst text = await c.req.text(); // Plain text\n```\n\n## Requirements\n\n- Node.js 16 or higher\n- Hono 3.x or 4.x\n\n## Development\n\n### Build from Source\n\n```bash\n# Clone the repository\ngit clone https://github.com/aibnuhibban/bytedocs-node.git\ncd bytedocs-node/hono\n\n# Install dependencies\nnpm install\n\n# Build the package\nnpm run build\n\n# Run example\nnpm run example\n# Visit http://localhost:3000/docs\n```\n\n### Development Mode\n\n```bash\n# Start development server with hot reload\nnpm run dev\n```\n\n## Examples\n\nCheck out the `examples/` directory for complete implementations:\n\n- **Basic**: `examples/basic/` - Simple setup with auto-detection\n- More examples coming soon!\n\n## Contributing\n\nWe welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n- 📖 [Documentation](https://github.com/aibnuhibban/bytedocs)\n- 🐛 [Report Issues](https://github.com/aibnuhibban/bytedocs-node/issues)\n- 💬 [GitHub Discussions](https://github.com/aibnuhibban/bytedocs/discussions)\n\n## Credits\n\n- Inspired by [Scramble for Laravel](https://scramble.dedoc.co/)\n- Part of the ByteDocs project\n- Built specifically for the [Hono](https://hono.dev/) web framework\n\n---\n\n**Made with ❤️ for the Hono community**\n","readmeFilename":"README.md"}