{"_id":"@dmitryrechkin/request-sender-core","_rev":"3-3b1c5f3ac85a14bbaec79a3186c9717a","name":"@dmitryrechkin/request-sender-core","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@dmitryrechkin/request-sender-core","version":"1.0.0","_id":"@dmitryrechkin/request-sender-core@1.0.0","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"dist":{"shasum":"4346108450ea834c171707af82c1fff13abaaa30","tarball":"https://registry.npmjs.org/@dmitryrechkin/request-sender-core/-/request-sender-core-1.0.0.tgz","fileCount":11,"integrity":"sha512-Q1omMqOWGKz+HgHkvslImmJ2TLtleJLEHhY5t0OIdSaGHE4y5TRSkohoygAzWq0PYjReEJ7ueedy4N8+JDKV3A==","signatures":[{"sig":"MEUCIQCtFJQPCU4x3rehM+bfKMjRu7MERN3sRY3cny6Mqpu7CAIgUQ3BpHOAxQ0i+7zJZ+9TDcYyE+zOb9OCm1ugOTo0QBQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45281},"main":"dist/index.js","type":"module","_from":"file:dmitryrechkin-request-sender-core-1.0.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","check":"tsc --noEmit","format":"eslint --fix .","package:publish":"pnpm publish --access public"},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/b8f6b108f9bc98e5fefa36034839d5df/dmitryrechkin-request-sender-core-1.0.0.tgz","_integrity":"sha512-Q1omMqOWGKz+HgHkvslImmJ2TLtleJLEHhY5t0OIdSaGHE4y5TRSkohoygAzWq0PYjReEJ7ueedy4N8+JDKV3A==","_npmVersion":"10.8.2","description":"**Request Sender Core is a TypeScript library that provides a unified and extensible interface for sending HTTP requests.** This library is designed to be the foundation for implementing request-sending adapters, allowing you to easily integrate with vari","directories":{},"_nodeVersion":"22.5.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"shx":"^0.3.4","dotenv":"^16.4.5","eslint":"^8.0.0","vitest":"^0.24.5","typescript":"^5.5.3","tsconfig-paths":"^4.2.0","fix-esm-import-path":"^1.0.1","eslint-plugin-unused-imports":"^3.0.0","@dmitryrechkin/eslint-standard":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/request-sender-core_1.0.0_1724727979456_0.30142252285504934","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@dmitryrechkin/request-sender-core","version":"1.0.1","_id":"@dmitryrechkin/request-sender-core@1.0.1","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"dist":{"shasum":"6b4e7938f6465e2855215be35af411141c8b8675","tarball":"https://registry.npmjs.org/@dmitryrechkin/request-sender-core/-/request-sender-core-1.0.1.tgz","fileCount":11,"integrity":"sha512-P+XUjNqDBN4u+5GjPBDuntmZOJ/qubbEgY9U1DLa07sxWD8E8RwKBNtEeFFetZeI+M9XQbizLRyVYqRk/qn7YA==","signatures":[{"sig":"MEQCIBVb6a/UloGd16LDGgdEWaKTYm4WVtrWG1PxxSSG/XJuAiBaUQdxdeXBQM2pqABbfUUoatcGqwJAdgbVjGdWoJIe8w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45387},"main":"dist/index.js","type":"module","_from":"file:dmitryrechkin-request-sender-core-1.0.1.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","check":"tsc --noEmit","format":"eslint --fix .","package:publish":"pnpm publish --access public"},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/f8911b78725162681b9127389daafd10/dmitryrechkin-request-sender-core-1.0.1.tgz","_integrity":"sha512-P+XUjNqDBN4u+5GjPBDuntmZOJ/qubbEgY9U1DLa07sxWD8E8RwKBNtEeFFetZeI+M9XQbizLRyVYqRk/qn7YA==","_npmVersion":"10.8.2","description":"**Request Sender Core is a TypeScript library that provides a unified and extensible interface for sending HTTP requests.** This library is designed to be the foundation for implementing request-sending adapters, allowing you to easily integrate with vari","directories":{},"_nodeVersion":"22.5.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"shx":"^0.3.4","dotenv":"^16.4.5","eslint":"^8.0.0","vitest":"^0.24.5","typescript":"^5.5.3","tsconfig-paths":"^4.2.0","fix-esm-import-path":"^1.0.1","eslint-plugin-unused-imports":"^3.0.0","@dmitryrechkin/eslint-standard":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/request-sender-core_1.0.1_1724861512678_0.2092067359271701","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@dmitryrechkin/request-sender-core","version":"1.0.2","_id":"@dmitryrechkin/request-sender-core@1.0.2","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"dist":{"shasum":"95fb51094ff7fe6175a065620fd76245e3827ad5","tarball":"https://registry.npmjs.org/@dmitryrechkin/request-sender-core/-/request-sender-core-1.0.2.tgz","fileCount":11,"integrity":"sha512-W7PX2/mQGrdBGcRkqQL5iveFRuRNq1ujxTt0bvzQnOtMXJOVGIIuJcpk1ShbkpxY7M+aAu/7szwW0rW9IbOw1w==","signatures":[{"sig":"MEUCIGmdlBwt+Cqy3hvHJZ09Xj2Y4HSzZMzgiehYOmnuIsLDAiEA45SLSEv0azPR38djxqhtoKJC6M0ZIZaHpWJmAHB4SME=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44498},"main":"dist/index.js","type":"module","_from":"file:dmitryrechkin-request-sender-core-1.0.2.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","check":"tsc --noEmit","format":"eslint --fix .","package:publish":"pnpm publish --access public"},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/c5c806d2b7aa321f5d62e88d62a7ccd8/dmitryrechkin-request-sender-core-1.0.2.tgz","_integrity":"sha512-W7PX2/mQGrdBGcRkqQL5iveFRuRNq1ujxTt0bvzQnOtMXJOVGIIuJcpk1ShbkpxY7M+aAu/7szwW0rW9IbOw1w==","_npmVersion":"10.8.2","description":"**Request Sender Core is a TypeScript library that provides a unified and extensible interface for sending HTTP requests.** This library is designed to be the foundation for implementing request-sending adapters, allowing you to easily integrate with vari","directories":{},"_nodeVersion":"22.5.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"shx":"^0.3.4","dotenv":"^16.4.5","eslint":"^8.0.0","vitest":"^0.24.5","typescript":"^5.5.3","tsconfig-paths":"^4.2.0","fix-esm-import-path":"^1.0.1","eslint-plugin-unused-imports":"^3.0.0","@dmitryrechkin/eslint-standard":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/request-sender-core_1.0.2_1724862531058_0.026163180308195866","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@dmitryrechkin/request-sender-core","type":"module","version":"1.0.3","main":"dist/index.js","types":"dist/index.d.ts","devDependencies":{"fix-esm-import-path":"^1.0.1","@dmitryrechkin/eslint-standard":"^1.0.7","dotenv":"^16.4.5","eslint":"^8.0.0","eslint-plugin-unused-imports":"^3.0.0","tsconfig-paths":"^4.2.0","typescript":"^5.5.3","vitest":"^0.24.5","shx":"^0.3.4"},"dependencies":{},"scripts":{"lint":"eslint .","format":"eslint --fix .","test":"vitest run","check":"tsc --noEmit","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","package:publish":"pnpm publish --access public"},"_id":"@dmitryrechkin/request-sender-core@1.0.3","description":"**Request Sender Core is a TypeScript library that provides a unified and extensible interface for sending HTTP requests.** This library is designed to be the foundation for implementing request-sending adapters, allowing you to easily integrate with vari","_integrity":"sha512-QzlEjZwhtQjIUvIvxEcMHbrvHZ3jh4XklGsElju9w7oVNJnggJox+3s2S/CMApqSoDct3EnVCvX8XYWAlEJN3w==","_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/3412e015ff3a6c1a116502af9f05feb8/dmitryrechkin-request-sender-core-1.0.3.tgz","_from":"file:dmitryrechkin-request-sender-core-1.0.3.tgz","_nodeVersion":"22.5.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-QzlEjZwhtQjIUvIvxEcMHbrvHZ3jh4XklGsElju9w7oVNJnggJox+3s2S/CMApqSoDct3EnVCvX8XYWAlEJN3w==","shasum":"a1141b0c44c18df3464ec954bbc6b05020f252d2","tarball":"https://registry.npmjs.org/@dmitryrechkin/request-sender-core/-/request-sender-core-1.0.3.tgz","fileCount":11,"unpackedSize":44614,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQChTk7hmEqoQGse4ldp0MlFT6vzckKpWg4BTR/FSyZpiAIgZo0GEMHeCO4dgrJlAFUjAUQelkneDEGbm00voQ4aucI="}]},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"directories":{},"maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/request-sender-core_1.0.3_1725132534122_0.607492065705401"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-27T03:06:19.357Z","modified":"2024-08-31T19:28:54.529Z","1.0.0":"2024-08-27T03:06:19.581Z","1.0.1":"2024-08-28T16:11:52.855Z","1.0.2":"2024-08-28T16:28:51.234Z","1.0.3":"2024-08-31T19:28:54.361Z"},"description":"**Request Sender Core is a TypeScript library that provides a unified and extensible interface for sending HTTP requests.** This library is designed to be the foundation for implementing request-sending adapters, allowing you to easily integrate with vari","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"readme":"\n# Request Sender Core\n\n**Request Sender Core is a TypeScript library that provides a unified and extensible interface for sending HTTP requests.** This library is designed to be the foundation for implementing request-sending adapters, allowing you to easily integrate with various APIs or services while keeping your codebase clean and consistent.\n\n## Installation\n\nInstall the package using pnpm:\n\n```bash\npnpm add @dmitryrechkin/request-sender-core\n```\n\n## Features\n\n- **Unified Interface**: A single interface (`RequestSenderInterface`) to handle HTTP requests, making it easy to swap out implementations without changing the consumer code.\n- **Factory Pattern**: Use the `RequestSenderFactoryInterface` to create instances of request senders, allowing for dynamic instantiation based on specific requirements.\n- **Extensibility**: Easily extend the library using the Adapter Pattern to create specialized request senders for different services.\n- **Error Handling**: Built-in error handling for network failures, returning custom responses to ensure consistent behavior.\n\n## Usage\n\n### Sending a Basic HTTP Request\n\n```typescript\nimport { HttpRequestSender } from \"@dmitryrechkin/request-sender-core\";\n\nconst requestSender = new HttpRequestSender();\nconst response = await requestSender.send('https://example.com/api', {\n    method: 'GET',\n    headers: { 'Content-Type': 'application/json' },\n});\n\nconsole.log('Response status:', response.status);\n```\n\n### Using the Factory Pattern\n\nThe factory pattern allows you to create instances of `RequestSenderInterface` dynamically, which can be useful in scenarios where you need different implementations based on runtime conditions.\n\n#### Creating a Factory\n\nFirst, implement the `RequestSenderFactoryInterface`:\n\n```typescript\nimport { RequestSenderFactoryInterface } from \"@dmitryrechkin/request-sender-core\";\nimport { HttpRequestSender } from \"@dmitryrechkin/request-sender-core\";\n\nexport class HttpRequestSenderFactory implements RequestSenderFactoryInterface {\n    public create(...args: unknown[]): HttpRequestSender {\n        // Create and return a new HttpRequestSender instance\n        return new HttpRequestSender();\n    }\n}\n```\n\n#### Using the Factory to Create a Request Sender\n\n```typescript\nimport { HttpRequestSenderFactory } from './HttpRequestSenderFactory';\n\nconst factory = new HttpRequestSenderFactory();\nconst requestSender = factory.create(); // Create a new HttpRequestSender instance\n\nconst response = await requestSender.send('https://example.com/api', {\n    method: 'POST',\n    body: JSON.stringify({ key: 'value' }),\n});\n\nconsole.log('Response status:', response.status);\n```\n\n### Extending with Custom Adapters\n\nTo create a specialized adapter for a specific service, implement the `RequestSenderInterface`:\n\n```typescript\nimport { RequestSenderInterface } from \"@dmitryrechkin/request-sender-core\";\n\nexport class CustomServiceRequestSender implements RequestSenderInterface {\n    public async send(url: string, options: RequestInit = {}): Promise<Response> {\n        // Custom implementation for sending requests to your specific service\n        return fetch(url, {\n            ...options,\n            // Add custom logic here\n        });\n    }\n}\n```\n\n### Using a Custom Adapter with a Factory\n\nYou can also create a factory for your custom adapter:\n\n```typescript\nimport { RequestSenderFactoryInterface } from \"@dmitryrechkin/request-sender-core\";\nimport { CustomServiceRequestSender } from './CustomServiceRequestSender';\n\nexport class CustomServiceRequestSenderFactory implements RequestSenderFactoryInterface {\n    public create(...args: unknown[]): CustomServiceRequestSender {\n        return new CustomServiceRequestSender();\n    }\n}\n```\n\nThis pattern allows you to abstract away the creation logic and use the same factory interface for different implementations, providing flexibility and modularity in your codebase.\n\n## When to Use\n\n`Request Sender Core` is ideal for projects that require a flexible and maintainable approach to handling HTTP requests, such as:\n\n- **API Integrations**: Build integrations with various APIs using a consistent interface.\n- **Service Adapters**: Create custom adapters for different services, ensuring your codebase remains clean and modular.\n- **Error-Resilient Applications**: Leverage built-in error handling to manage network failures and ensure consistent responses.\n- **Dynamic Request Handling**: Use factories to dynamically create instances of request senders based on runtime conditions.\n\n## Installation & Setup\n\nInstall the package using pnpm:\n\n```bash\npnpm add @dmitryrechkin/request-sender-core\n```\n\nEnsure your project is set up to handle TypeScript and supports ES modules, as this library is built with modern JavaScript standards.\n\n## Rationale\n\n### Extensibility with the Adapter and Factory Patterns\n\nThe `Request Sender Core` library is built with extensibility in mind, using both the Adapter and Factory Patterns. These patterns allow you to:\n\n- **Decouple Implementation from Usage**: The consumer code only interacts with interfaces, not specific implementations. This makes it easier to switch out implementations as needed.\n- **Promote Reusability**: Create adapters and factories that can be reused across different projects or modules, saving time and effort.\n- **Simplify Testing**: With consistent interfaces, testing becomes easier since you can mock or replace implementations without modifying the tests themselves.\n- **Dynamic Instantiation**: The factory pattern allows for flexible and dynamic creation of request sender instances, tailored to the specific needs of your application.\n\n## Contributing\n\nContributions are welcome! Feel free to fork this project and submit pull requests. Before submitting, please ensure your code passes all linting and unit tests.\n\nYou can run unit tests using:\n\n```bash\npnpm test\n```\n","readmeFilename":"README.md"}