{"_id":"apirules-sdk","_rev":"31-03fb97405cbf066d7c183b0c18487c6e","name":"apirules-sdk","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"apirules-sdk","version":"1.0.0","author":{"name":"ApiRules"},"license":"ISC","_id":"apirules-sdk@1.0.0","maintainers":[{"name":"rerm","email":"sqa.rerm@gmail.com"}],"dist":{"shasum":"190d003fd3a4133692dcf6e53785361f8e34814c","tarball":"https://registry.npmjs.org/apirules-sdk/-/apirules-sdk-1.0.0.tgz","fileCount":4,"integrity":"sha512-8z/bhMsRnvzItAqID7sP74VJwDrcebDKv+SKby3xRzZxfarEWS9miFUyMpL9G65G0VXenLX/DR01v4Au148Rfg==","signatures":[{"sig":"MEYCIQDCCYOX2M/Mt4gE8Ef24dINBQxu9a736nKbF6O21AsWEAIhAN4cCsvsF+9otl+3q5RdmC2d1CjoDF8+VLFEiXyw8LHJ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4048},"main":"index.js","type":"module","gitHead":"109af186d549daed464736f943e7cd87a0625acd","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"_npmUser":{"name":"rerm","email":"sqa.rerm@gmail.com"},"_npmVersion":"10.9.2","description":"Api Rules SDK","directories":{},"_nodeVersion":"23.11.0","dependencies":{"axios":"^1.9.0","express":"^5.1.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^22.15.21","@types/express":"^5.0.2"},"_npmOperationalInternal":{"tmp":"tmp/apirules-sdk_1.0.0_1747999986377_0.7549193191608543","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"apirules-sdk","version":"1.1.0","author":{"name":"ApiRules"},"license":"ISC","_id":"apirules-sdk@1.1.0","maintainers":[{"name":"rerm","email":"sqa.rerm@gmail.com"}],"dist":{"shasum":"8bbcddeaa1aac2e3daa09f693dd8ec049c65d8ce","tarball":"https://registry.npmjs.org/apirules-sdk/-/apirules-sdk-1.1.0.tgz","fileCount":4,"integrity":"sha512-XRV8yZE7RFnNTJj2jjpRRnp5lULhnquT7886pYv9uvMBRSZU5CTAazOGV1Y/mw0anO/n1R7Rt4mKv7BlK64/uQ==","signatures":[{"sig":"MEUCICqSzrhlKgdTEZq8Viw00NDAPChdnpn+w37tN3/p9CkMAiEA2aCqKgiZ7pmR5wWaq0hv8QLupDlab87/rNEFg5AgmwQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4526},"main":"index.js","type":"module","exports":{".":"./dist/index.js"},"gitHead":"47b8d05da9878b3660d0a491d5ec6f2aa184a951","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"_npmUser":{"name":"rerm","email":"sqa.rerm@gmail.com"},"_npmVersion":"10.9.2","description":"Api Rules SDK","directories":{},"_nodeVersion":"23.11.0","dependencies":{"axios":"^1.9.0","express":"^5.1.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^22.15.21","@types/express":"^5.0.2"},"_npmOperationalInternal":{"tmp":"tmp/apirules-sdk_1.1.0_1749152956706_0.8106573098857863","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"apirules-sdk","version":"1.1.1","description":"Api Rules SDK","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"exports":{".":"./dist/index.js"},"author":{"name":"ApiRules"},"license":"ISC","type":"module","dependencies":{"axios":"^1.9.0","express":"^5.1.0"},"devDependencies":{"@types/express":"^5.0.2","@types/node":"^22.15.21","typescript":"^5.8.3"},"_id":"apirules-sdk@1.1.1","gitHead":"ecd0fa179a93b285081f231e7ffaaa410899bfef","_nodeVersion":"23.11.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-UQd7lw+zxVm21HFpDjvIfspjIjuvQOo6F/0lUEV0YtJJp8+HIO7ZR86pz7ttly2hwWJ6mSO4LoseKysIOPMSYg==","shasum":"eea457730cd2ec0ebbdcfc4c0fd94985096dd4a1","tarball":"https://registry.npmjs.org/apirules-sdk/-/apirules-sdk-1.1.1.tgz","fileCount":4,"unpackedSize":4696,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEDzVsKNfC/AkPTu+jLNX4HpyR4bRr1NEvRPeHE2H5g1AiEApFHhfPw/IG3Cz3uzUP76m1+FY6R1uRhs3Fo/Z1vAgIM="}]},"_npmUser":{"name":"rerm","email":"sqa.rerm@gmail.com"},"directories":{},"maintainers":[{"name":"rerm","email":"sqa.rerm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/apirules-sdk_1.1.1_1749379257650_0.15782489889642903"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-23T11:33:06.376Z","modified":"2025-06-08T10:40:58.018Z","1.0.0":"2025-05-23T11:33:06.547Z","1.0.1":"2025-05-23T11:40:19.022Z","1.0.2":"2025-05-28T13:24:57.056Z","1.0.3":"2025-05-29T09:26:56.390Z","1.0.4":"2025-05-29T09:30:13.349Z","1.0.5":"2025-05-29T09:31:23.980Z","1.0.6":"2025-05-29T09:33:20.654Z","1.0.7":"2025-05-29T09:36:13.146Z","1.0.8":"2025-06-03T07:51:04.619Z","1.0.9":"2025-06-03T07:51:40.165Z","1.0.10":"2025-06-03T08:13:35.045Z","1.0.11":"2025-06-03T08:14:24.366Z","1.0.20":"2025-06-03T19:54:21.604Z","1.0.21":"2025-06-03T20:27:39.112Z","1.0.22":"2025-06-05T19:15:58.087Z","1.1.0":"2025-06-05T19:49:16.887Z","1.1.1":"2025-06-08T10:40:57.860Z"},"author":{"name":"ApiRules"},"license":"ISC","description":"Api Rules SDK","maintainers":[{"name":"rerm","email":"sqa.rerm@gmail.com"}],"readme":"# API Rules SDK\n\nA middleware SDK for protecting your API endpoints with rules defined in the API Rules dashboard.\n\n## Installation\n\n```bash\nnpm install apirules-sdk\n```\n\n## Quick Start\n\n```javascript\nimport express from 'express';\nimport ApiRules from 'apirules-sdk';\n\nconst app = express();\nconst apiRules = new ApiRules('your-api-key');\n\n// Protect a route with API Rules where your-endpoint-id is ID set in Dashboard\napp.post('/your-endpoint', apiRules.validate('your-endpoint-id'), (req, res) => {\n    // Your route handler\n    res.send('Protected endpoint');\n});\n```\n\n## Configuration\n\n```javascript\nconst apiRules = new ApiRules('your-api-key', {\n    apiUrl: 'http://api.apirules.io/api' // Optional custom API URL\n});\n```\n\n## How It Works\n\n1. The middleware intercepts requests to your endpoints\n2. It sends the request body to the API Rules service for validation\n3. If the request is allowed, it proceeds to your route handler\n4. If blocked, it returns a 403 status code\n\n## Error Handling\n\n- If the API Rules service is unavailable, requests will be allowed by default\n- If you hit the rate limit the reques will be allowed by default\n- All errors are passed to Express's error handling middleware\n\n## Example\n\n```javascript\nimport express from 'express';\nimport ApiRules from 'apirules-sdk';\n\nconst app = express();\nconst apiRules = new ApiRules('your-api-key');\n\n// Protected endpoint\napp.post('/api/data', apiRules.validate('endpoint-123'), (req, res) => {\n    res.json({ message: 'Request allowed' });\n});\n\napp.listen(3000, () => {\n    console.log('Server running on port 3000');\n});\n```\n\n## License\n\nISC\n\n","readmeFilename":"README.md"}