{"_id":"@8zali9/server-z","_rev":"1-09147f402f461206a8e000e580267cee","name":"@8zali9/server-z","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@8zali9/server-z","version":"1.0.0","author":{"name":"Zulfiqar"},"license":"ISC","_id":"@8zali9/server-z@1.0.0","maintainers":[{"name":"8zali9","email":"8zali9@gmail.com"}],"homepage":"https://github.com/8zali9/server-z#readme","bugs":{"url":"https://github.com/8zali9/server-z/issues"},"dist":{"shasum":"a649032987fcf530d629a0d428459077d8d1a00d","tarball":"https://registry.npmjs.org/@8zali9/server-z/-/server-z-1.0.0.tgz","fileCount":3,"integrity":"sha512-zBr2oErxhPhKOB2ss/0je4wdLTGSo/scvtDz+kict+RiSK+zVxT/5VEcCSQKzlChWe1JU+qkxN8AmrIBgFykrw==","signatures":[{"sig":"MEUCIQCC+SIQ+oLlPQU59um08WZ0mW0dHWE2vMlFDAAPuaQsPAIgNAXAry4jZqh+MIi/C0eqpdsh9wu637LGxusrXCAI7T4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1656},"main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"8zali9","email":"8zali9@gmail.com"},"repository":{"url":"git+https://github.com/8zali9/server-z.git","type":"git"},"_npmVersion":"10.7.0","description":"npm package to create http server","directories":{},"_nodeVersion":"20.15.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/server-z_1.0.0_1727454795878_0.10453563402532473","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@8zali9/server-z","version":"1.1.0","description":"npm package to create http server","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/8zali9/server-z.git"},"author":{"name":"Zulfiqar"},"license":"ISC","bugs":{"url":"https://github.com/8zali9/server-z/issues"},"homepage":"https://github.com/8zali9/server-z#readme","_id":"@8zali9/server-z@1.1.0","gitHead":"72a78eae167436ece36059e8f576cca7aa019b5a","_nodeVersion":"20.15.1","_npmVersion":"10.7.0","dist":{"integrity":"sha512-d+e3Rcz1jISKx81PuwP564m6jF7Dj2HBPIpu3T0RwuphL8xAeFDwB3XX6wAxweiMjcOXhH+55GnTAXikBY+XcQ==","shasum":"dce9a418f1b7899d96051c081f9f80c0a4061cbd","tarball":"https://registry.npmjs.org/@8zali9/server-z/-/server-z-1.1.0.tgz","fileCount":4,"unpackedSize":4307,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEIDT2gll7rX6kL/YVz/LwuicemdAqdrD8aofscSIkpRAiEAzFgg/St2ycAP3rChK3YRYdDpn+jQm7IGHXtay3kZWWk="}]},"_npmUser":{"name":"8zali9","email":"8zali9@gmail.com"},"directories":{},"maintainers":[{"name":"8zali9","email":"8zali9@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/server-z_1.1.0_1727624859287_0.26989289311273"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-27T16:33:15.769Z","modified":"2024-09-29T15:47:39.659Z","1.0.0":"2024-09-27T16:33:16.078Z","1.1.0":"2024-09-29T15:47:39.497Z"},"bugs":{"url":"https://github.com/8zali9/server-z/issues"},"author":{"name":"Zulfiqar"},"license":"ISC","homepage":"https://github.com/8zali9/server-z#readme","repository":{"type":"git","url":"git+https://github.com/8zali9/server-z.git"},"description":"npm package to create http server","maintainers":[{"name":"8zali9","email":"8zali9@gmail.com"}],"readme":"# Server-Z\r\n\r\n`server-z` is an npm package that allows you to create a simple HTTP server and offload CPU-intensive tasks to worker threads, preventing blocking of the event loop or the main thread.\r\n\r\n\r\n## Features\r\n\r\n1. **Simple HTTP Server Creation**:\r\n   - Easily set up an HTTP server with methods to handle `GET`, `POST`, `UPDATE`, and `DELETE` requests.\r\n   \r\n2. **Offload CPU-Intensive Task**:\r\n   - Execute a CPU-intensive task on a worker thread without blocking the main thread, ensuring smooth performance for I/O operations.\r\n\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @8zali9/server-z\r\n```\r\n\r\n\r\n## Example - Creating an http server\r\n\r\n```bash\r\nconst serverz = require(\"@8zali9/server-z\")\r\nconst app = new serverz()\r\n\r\napp.getReq(\"/\", (req, res) => {\r\n    res.end(\"hello\")\r\n})\r\n\r\napp.listen(3000, () => {})\r\n```\r\n\r\n\r\n## Example - Offload CPU-Intensive Task\r\n\r\n```bash\r\nconst { CPUIntensiveTaskExecuter } = require(\"./index\")\r\n\r\nconst main = () => {\r\n    return 89\r\n}\r\n\r\nconst ite = new CPUIntensiveTaskExecuter(main)\r\n\r\nconst callback = (result) => {\r\n    console.log(`callback done: ${result}`)\r\n}\r\n\r\nite.executeCpuIntensiveTask(callback)\r\n```\r\n\r\n\r\n## API Reference\r\n\r\n**ServerZ**\r\n- getReq(url, handler): Handle GET requests at the specified URL.\r\n- postReq(url, handler): Handle POST requests at the specified URL.\r\n- updateReq(url, handler): Handle UPDATE requests at the specified URL.\r\n- deleteReq(url, handler): Handle DELETE requests at the specified URL.\r\n- listen(port, callback): Start the HTTP server on the specified port.\r\n\r\n**IntensiveTaskExecuter**\r\n- constructor(mainFunction): Initializes the task executor with the CPU-intensive task.\r\n- executeCpuIntensiveTask(callback): Executes the task on a worker thread and returns the result through the callback.\r\n\r\n\r\n## License\r\n\r\nMIT\r\n\r\nThis `README.md` provides a clear introduction, installation instructions, examples for HTTP server creation, and offloading CPU-intensive tasks, and an API reference for your package.","readmeFilename":"readme.md"}