{"id":15603246,"url":"https://github.com/codemeasandwich/api-ape","last_synced_at":"2026-01-21T12:11:11.162Z","repository":{"id":64411746,"uuid":"574264034","full_name":"codemeasandwich/api-ape","owner":"codemeasandwich","description":"RPE: Remote procedure events","archived":false,"fork":false,"pushed_at":"2026-01-17T09:02:49.000Z","size":5824,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-17T17:47:38.270Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemeasandwich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-12-04T22:55:15.000Z","updated_at":"2026-01-17T07:14:18.000Z","dependencies_parsed_at":"2023-01-29T15:31:16.791Z","dependency_job_id":null,"html_url":"https://github.com/codemeasandwich/api-ape","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/codemeasandwich/api-ape","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fapi-ape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fapi-ape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fapi-ape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fapi-ape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemeasandwich","download_url":"https://codeload.github.com/codemeasandwich/api-ape/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fapi-ape/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28632782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T03:02:09.636Z","updated_at":"2026-01-21T12:11:11.139Z","avatar_url":"https://github.com/codemeasandwich.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🦍 api-ape\n\n[![npm version](https://img.shields.io/npm/v/api-ape.svg)](https://www.npmjs.com/package/api-ape)\n[![GitHub issues](https://img.shields.io/github/issues/codemeasandwich/api-ape)](https://github.com/codemeasandwich/api-ape/issues)\n[![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](server/README.md#zero-dependency-websocket)\n[![Dependabot](https://img.shields.io/dependabot/codemeasandwich/api-ape)](https://github.com/codemeasandwich/api-ape/security/dependabot)\n[![CSRF protected](https://img.shields.io/badge/CSRF%20🚷-protected-green.svg)](client/README.md#security)\n[![Bundle Size](https://img.shields.io/bundlephobia/minzip/api-ape)](https://bundlephobia.com/package/api-ape)\n[![JSS Encoding](https://img.shields.io/badge/encoding-JSS-blue.svg)](server/README.md)\n[![license](https://img.shields.io/npm/l/api-ape.svg)](https://github.com/codemeasandwich/api-ape/blob/main/LICENSE)\n\n![api-ape logo](assets/apiApeLogo.jpg)\n\n**Remote Procedure Events (RPE)** — A lightweight WebSocket framework for building real-time APIs. Call server functions from the browser like local methods. Get real-time broadcasts with zero setup.\n\n---\n\n## Install\n\n```bash\nnpm install api-ape\n```\n\n**Requirements:** Node.js 14+ (for server), modern browsers (for client)\n\n---\n\n## Quick Start\n\n### Server (`ape`)\n\n```js\nconst { createServer } = require('http')\nconst { ape } = require('api-ape')\n\nconst server = createServer()\nape(server, { where: 'api' })  // Load controllers from ./api folder\nserver.listen(3000)\n```\n\n### Controllers\n\nDrop a file in your `api/` folder — it automatically becomes an endpoint:\n\n```js\n// api/hello.js\nmodule.exports = function(name) {\n  return `Hello, ${name}!`\n}\n\n// api/message.js  \nmodule.exports = function(text) {\n  this.broadcastOthers('message', { text, from: this.clientId })\n  return { sent: true }\n}\n```\n\n### Client (`api`)\n\n**Browser:**\n```html\n\u003cscript src=\"/api/ape.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const result = await api.hello('World')  // \"Hello, World!\"\n\n  // Subscribe to messages (pass a callback)\n  const unsub = api.message(data =\u003e console.log(data))\n\u003c/script\u003e\n```\n\n**Bundlers (React, Vue, etc.):**\n```js\nimport api from 'api-ape'\n\nconst result = await api.hello('World')\n\n// Subscribe (pass callback) vs RPC call (pass data)\nconst unsub = api.message(data =\u003e console.log(data))  // Subscribe\nawait api.message({ text: 'Hello' })                   // RPC call\n```\n\n---\n\n## Key Concepts\n\n* **[Auto-wiring](server/README.md#auto-routing)** — Drop JS files in a folder, they become API endpoints\n* **[Real-time broadcasts](server/README.md#controller-context-this)** — Built-in `broadcast()` and `broadcastOthers()` methods\n* **[Pub/Sub channels](server/README.md#pubsub-channels)** — Clients subscribe to channels, server publishes updates\n* **[Promise-based calls](client/README.md#usage)** — `api.users.list()` maps to `api/users/list.js`\n* **[Automatic reconnection](client/README.md#features)** — Client reconnects with exponential backoff\n* **[HTTP fallback](server/README.md#http-streaming-endpoints)** — Falls back to long polling when WebSockets are blocked\n* **[JSS Encoding](server/README.md#troubleshooting--faq)** — Supports Date, RegExp, Error, Set, Map over the wire\n* **[🌲 Forest](server/README.md#-forest-distributed-mesh)** — Distributed mesh for horizontal scaling\n* **[🔐 Authentication](server/README.md#authentication)** — OPAQUE/PAKE auth with tiered access control\n\n---\n\n## Examples\n\n* **[`example/ExpressJs/`](example/ExpressJs/)** — Simple real-time chat\n* **[`example/NextJs/`](example/NextJs/)** — Production chat with React \u0026 Docker\n* **[`example/Vite/`](example/Vite/)** — Vite + Vue\n* **[`example/Bun/`](example/Bun/)** — Bun runtime\n\n```bash\ncd example/ExpressJs \u0026\u0026 npm install \u0026\u0026 npm start\n```\n\n---\n\n## Documentation\n\n| Docs | Description |\n|------|-------------|\n| **[Server README](server/README.md)** | API reference, lifecycle hooks, auto-routing, file transfers, 🌲 Forest |\n| **[Client README](client/README.md)** | Client usage, connection states, file transfers, security |\n| **[Auth README](server/security/auth/README.md)** | OPAQUE authentication, tiered access, authorization |\n| **[Adapters README](server/adapters/README.md)** | Database adapters for Forest |\n\n---\n\n## Contributing\n\n1. Fork the repository\n2. Create a branch: `git checkout -b feature/your-feature`\n3. Make changes and add tests\n4. Run tests: `npm test`\n5. Push and open a PR\n\n### Tests\n\n```bash\nnpm test            # Run tests\nnpm run test:watch  # Watch mode\nnpm run test:cover  # Coverage\n```\n\n---\n\n## License\n\n**MIT** — [Brian Shannon](https://www.linkedin.com/in/brianshann/)\n\n**Made with 🦍 by the api-ape community**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemeasandwich%2Fapi-ape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemeasandwich%2Fapi-ape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemeasandwich%2Fapi-ape/lists"}