{"_id":"0xapi","_rev":"4-73bafea6b8a0bcd682314b2deaca77ee","name":"0xapi","dist-tags":{"latest":"1.1.0"},"versions":{"0.0.1":{"name":"0xapi","version":"0.0.1","keywords":["express","api","authentication","lightweight","rate-limiter","wrapper"],"author":{"name":"ShadyMoon","email":"shady.js"},"license":"MIT","_id":"0xapi@0.0.1","maintainers":[{"name":"shadymoon","email":"tccraven2020@gmail.com"}],"homepage":"https://github.com/ShadyM00n/0xapi#readme","bugs":{"url":"https://github.com/ShadyM00n/0xapi/issues"},"dist":{"shasum":"cf1894092a912052d41ed92934d5015495eb934a","tarball":"https://registry.npmjs.org/0xapi/-/0xapi-0.0.1.tgz","fileCount":9,"integrity":"sha512-qyMxqYK5AOMWhgveYZ7XQY4rWpiNx/BEh9YAiUrD1iP9wO7oEKniJJYkCZvS4XK1CUWjnOyLRUwUmA5lLVO8wg==","signatures":[{"sig":"MEYCIQDHD8m7GbaFAPP5y4i3YZHJDzITB4ECG8rNLqtr2SMZ/AIhANvIOOBQL+jlHaOEHREELrFnTH5lahiQFdHif+LKWAeC","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9566},"main":"index.js","_npmUser":{"name":"shadymoon","email":"tccraven2020@gmail.com"},"repository":{"url":"git+https://github.com/ShadyM00n/0xapi.git","type":"git"},"_npmVersion":"10.9.2","description":"is a lightweight library for quickly setting up APIs with Express.","directories":{},"_nodeVersion":"23.6.0","dependencies":{"express":"^0.0.1-security"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/0xapi_0.0.1_1747005662123_0.848853744185001","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"0xapi","version":"1.0.0","keywords":["express","api","authentication","lightweight","rate-limiter","wrapper"],"author":{"name":"ShadyMoon","email":"shady.js"},"license":"MIT","_id":"0xapi@1.0.0","maintainers":[{"name":"shadymoon","email":"tccraven2020@gmail.com"}],"homepage":"https://github.com/ShadyM00n/0xapi#readme","bugs":{"url":"https://github.com/ShadyM00n/0xapi/issues"},"dist":{"shasum":"eef7d1eb60764dad60410367fa5553f0f75f85cf","tarball":"https://registry.npmjs.org/0xapi/-/0xapi-1.0.0.tgz","fileCount":9,"integrity":"sha512-W1bcUomAuOP4oiKG0UHYlq6pTwversO45v0zNs/0kizGiN+2C0n93Tx4TAs+XnJU/cScHaUpouLJkPzO9t0Cjg==","signatures":[{"sig":"MEQCIHLrHCDB2S2Eke/CsaAcdMhEFCRihSsoxEjTqD2TbwtWAiANScCpExQtBsqD8gznjjmXpUuf8e3HSD6ASUf711tY7w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9557},"main":"index.js","_npmUser":{"name":"shadymoon","email":"tccraven2020@gmail.com"},"repository":{"url":"git+https://github.com/ShadyM00n/0xapi.git","type":"git"},"_npmVersion":"10.9.2","description":"is a lightweight library for quickly setting up APIs with Express.","directories":{},"_nodeVersion":"23.6.0","dependencies":{"express":"^5.1.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/0xapi_1.0.0_1747005842483_0.949244855264711","host":"s3://npm-registry-packages-npm-production"}},"1.0.0-stable":{"name":"0xapi","version":"1.0.0-stable","keywords":["express","api","authentication","lightweight","rate-limiter","wrapper"],"author":{"name":"ShadyMoon","email":"shady.js"},"license":"MIT","_id":"0xapi@1.0.0-stable","maintainers":[{"name":"shadymoon","email":"tccraven2020@gmail.com"}],"homepage":"https://github.com/ShadyM00n/0xapi#readme","bugs":{"url":"https://github.com/ShadyM00n/0xapi/issues"},"dist":{"shasum":"c8ce9aba3a116054382c97aa1e3aa394d74a0238","tarball":"https://registry.npmjs.org/0xapi/-/0xapi-1.0.0-stable.tgz","fileCount":9,"integrity":"sha512-RuYz8fZaolWr8su6ocTz4Vp+G7i0IT+cxWI2DRoIS2LhsKxR1zdr2DtXRLgwiAuaqd7acej8ktr2AkNG3scTcg==","signatures":[{"sig":"MEYCIQCn1omu7LDoHmp/YJ/vtMQ7mI9Pu8WaRZm9WyhSfq8B8AIhALKqb5+YutTp1Chek/f4YYQt0dsQ7e1XaIrUw8kEPX0q","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9564},"main":"index.js","_npmUser":{"name":"shadymoon","email":"tccraven2020@gmail.com"},"repository":{"url":"git+https://github.com/ShadyM00n/0xapi.git","type":"git"},"_npmVersion":"10.9.2","description":"is a lightweight library for quickly setting up APIs with Express.","directories":{},"_nodeVersion":"23.6.0","dependencies":{"express":"^5.1.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/0xapi_1.0.0-stable_1747006179741_0.3123940854751044","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"0xapi","version":"1.1.0","description":"is a lightweight library for quickly setting up APIs with Express.","main":"index.js","author":{"name":"ShadyMoon","email":"shady.js"},"license":"MIT","keywords":["express","api","authentication","lightweight","rate-limiter","wrapper"],"repository":{"type":"git","url":"git+https://github.com/ShadyM00n/0xapi.git"},"bugs":{"url":"https://github.com/ShadyM00n/0xapi/issues"},"homepage":"https://github.com/ShadyM00n/0xapi#readme","dependencies":{"express":"^5.1.0","express-rate-limit":"^7.5.0"},"_id":"0xapi@1.1.0","_nodeVersion":"23.6.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-b8PqmkCdEXYgLlHVjcTQ+9DOh+1y8Rcz71WJOCn4EU2SOkrJoa36whTbmWgO0XRjrApa4Wif7pl5rtu9aaf88g==","shasum":"7df6aa3adddeff3a4569cdc74b1c7c7b987f49d7","tarball":"https://registry.npmjs.org/0xapi/-/0xapi-1.1.0.tgz","fileCount":9,"unpackedSize":9593,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCAXzxx8euYM0OFs2WtLbvl3J1c39ilMiGtFEWRfXzesQIgZOSiM3Kg2akzdR3tiRdaTaWbPqwioeMquFWEhuPgr7g="}]},"_npmUser":{"name":"shadymoon","email":"tccraven2020@gmail.com"},"directories":{},"maintainers":[{"name":"shadymoon","email":"tccraven2020@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/0xapi_1.1.0_1747006621715_0.6734936548343231"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-11T23:21:02.122Z","modified":"2025-05-11T23:37:02.104Z","0.0.1":"2025-05-11T23:21:02.280Z","1.0.0":"2025-05-11T23:24:02.664Z","1.0.0-stable":"2025-05-11T23:29:39.920Z","1.1.0":"2025-05-11T23:37:01.927Z"},"bugs":{"url":"https://github.com/ShadyM00n/0xapi/issues"},"author":{"name":"ShadyMoon","email":"shady.js"},"license":"MIT","homepage":"https://github.com/ShadyM00n/0xapi#readme","keywords":["express","api","authentication","lightweight","rate-limiter","wrapper"],"repository":{"type":"git","url":"git+https://github.com/ShadyM00n/0xapi.git"},"description":"is a lightweight library for quickly setting up APIs with Express.","maintainers":[{"name":"shadymoon","email":"tccraven2020@gmail.com"}],"readme":"# 0xapi\n\n`0xapi` is a lightweight library for quickly setting up APIs with Express. It simplifies the API creation process and ensures compatibility with popular Express extensions, like `express-rate-limit`. With minimal configuration, you can easily structure your API, manage routes, and extend your app's functionality.\n\n## Features\n\n- Simple API and router creation\n- Compatible with popular Express extensions (e.g., `express-rate-limit`)\n- Easy setup for versioned APIs\n- Flexible routing with minimal configuration\n- Built-in support for rate limiting, authentication, and more\n\n## Installation\n\nTo install `0xapi`, run the following command:\n\n```\nnpm install 0xapi\n```\n\n## Usage\n\n### Basic Setup\n\n`0xapi` allows you to create APIs with versioned routes. Below is an example of setting up a versioned API with rate limiting and authentication.\n\n```javascript\nconst { API, Router, Auth, RateLimiter } = require(\"0xapi\");\n\nconst Authization = new Auth([                      // Creates an auth gateway for your API.\n    \"cd9e7837-9194-4009-ad2c-b698368b8423\"\n]);\n\nconst apiV1Router = new Router({ name: \"V1 API\", path: \"/api/v1\" });           // Creates a route for /api/v1\nconst apiV2Router = new Router({ name: \"V2 API\", path: \"/api/v2\" });           // Creates a route for /api/v2\n\napiV1Router.get(\"/\", (req, res) => { res.json({ timestamp: Date.now() }); });  // Creates a GET endpoint at /api/v1/\napiV2Router.get(\"/\", (req, res) => { res.json({ timestamp: Date.now() }); });  // Creates a GET endpoint at /api/v2/\n\n// Rate limiter setup\nconst limiter = new RateLimiter({\n    window: 5 * 60 * 1000,  // Limit requests to every 5 minutes\n    max: 100,               // Max 100 requests per window\n    message: \"Too many requests from this IP, please try again later.\"\n});\n\nconst api = new API({                   // Creates an API instance.\n    port: 8081,                         // Set the API to run on port 8081.\n    Routers: [apiV1Router, apiV2Router]  // Attach versioned routers to the API.\n});\n\n// Apply the rate limiter globally\napi.use(limiter);\n\n// Apply the authorization gateway globally\napi.use(Authization);\n\napi.listen(() => {                      // Start the API.\n    console.log(\"API is running\");      // Log a message when the API starts.\n});\n```\n\n### Explanation\n\n- **Router Setup**: You define versioned routes (e.g., `/api/v1`, `/api/v2`) using `Router`. This helps organize your API endpoints into logical versions.\n\n- **Rate Limiting**: The `RateLimiter` class is used to limit the number of requests per IP in a 5-minute window (maximum of 100 requests). If the limit is exceeded, the message \"Too many requests from this IP, please try again later\" is sent.\n\n- **Authentication**: The `Auth` class provides an easy way to enforce authentication in your API. In the example, an API key `\"cd9e7837-9194-4009-ad2c-b698368b8423\"` is required for accessing the routes. If a request doesn't include a valid API key, it is denied.\n\n- **API Initialization**: Create an `API` instance, attach routers, and start the server on port `8081`. The rate limiter and authentication middleware are applied globally using `api.use()`.\n\n### Compatibility\n\n`0xapi` is fully compatible with popular Express extensions. In the above example, `RateLimiter` is used to manage the rate of requests, and `Auth` is used to secure the API. You can easily integrate other middlewares or extensions to suit your app’s needs.\n\n## Documentation\n\nFor more detailed documentation, visit the GitHub repository:\n\n[https://github.com/ShadyM00n/0xapi](https://github.com/ShadyM00n/0xapi)\n\n## Contributing\n\nFeel free to submit issues or pull requests. Contributions are welcome!\n\n## License\n\nMIT License. See the [License](License) file for more details.\n","readmeFilename":"README.MD"}