{"id":18358109,"url":"https://github.com/iamnnort/request","last_synced_at":"2026-02-20T21:07:06.895Z","repository":{"id":196236035,"uuid":"695484819","full_name":"iamnnort/request","owner":"iamnnort","description":"Request handler for Node.js - Fast - Interactive - Simple","archived":false,"fork":false,"pushed_at":"2026-01-13T14:00:59.000Z","size":191,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-13T16:51:23.005Z","etag":null,"topics":["ajax","fetch","http","promise","request","xhr"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@iamnnort/request","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamnnort.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","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":"2023-09-23T10:28:51.000Z","updated_at":"2026-01-13T14:01:12.000Z","dependencies_parsed_at":"2026-01-13T16:07:06.245Z","dependency_job_id":null,"html_url":"https://github.com/iamnnort/request","commit_stats":{"total_commits":51,"total_committers":1,"mean_commits":51.0,"dds":0.0,"last_synced_commit":"b29759dcfbef3030f484e9b027288ac328716397"},"previous_names":["iamnnort/request"],"tags_count":62,"template":false,"template_full_name":null,"purl":"pkg:github/iamnnort/request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnnort%2Frequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnnort%2Frequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnnort%2Frequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnnort%2Frequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamnnort","download_url":"https://codeload.github.com/iamnnort/request/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnnort%2Frequest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: 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":["ajax","fetch","http","promise","request","xhr"],"created_at":"2024-11-05T22:16:49.844Z","updated_at":"2026-02-20T21:07:06.888Z","avatar_url":"https://github.com/iamnnort.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @iamnnort/request\n\nRequest handler for Node.js - Fast - Interactive - Simple\n\n## Installation\n\n```bash\nnpm install @iamnnort/request\n# or\nyarn add @iamnnort/request\n```\n\n## Usage\n\n```typescript\nimport { HttpMethods, LoggerLevels, RequestDataSource } from '@iamnnort/request';\n\nclass TodoDataSource extends RequestDataSource {\n  constructor() {\n    super({\n      baseUrl: 'https://dummyjson.com',\n      url: '/todos',\n      logger: {\n        name: 'Todo Api',\n        level: LoggerLevels.INFO,\n      },\n    });\n  }\n\n  search() {\n    return this.common({\n      method: HttpMethods.GET,\n      params: {\n        limit: 10,\n      },\n    });\n  }\n\n  get(id: number) {\n    return this.common({\n      method: HttpMethods.GET,\n      url: id,\n    });\n  }\n\n  create(data: { todo: string; completed: boolean; userId: number }) {\n    return this.common({\n      method: HttpMethods.POST,\n      url: '/add',\n      data,\n    });\n  }\n\n  update(id: number, data: { completed: boolean }) {\n    return this.common({\n      method: HttpMethods.PUT,\n      url: id,\n      data,\n    });\n  }\n\n  remove(id: number) {\n    return this.common({\n      method: HttpMethods.DELETE,\n      url: id,\n    });\n  }\n}\n\nconst dataSource = new TodoDataSource();\n\nawait dataSource.search();\nawait dataSource.get(1);\nawait dataSource.create({ todo: 'Test todo', completed: false, userId: 1 });\nawait dataSource.update(1, { completed: true });\nawait dataSource.remove(1);\n```\n\n## Logging\n\nSet the `logger` option to enable it.\n\n```typescript\nimport { LoggerLevels, RequestDataSource } from '@iamnnort/request';\n\nconst dataSource = new RequestDataSource({\n  baseUrl: 'https://dummyjson.com',\n  url: '/todos',\n  logger: {\n    name: 'Todo Api',\n    level: LoggerLevels.DEBUG,\n  },\n});\n```\n\nLog levels: `trace`, `debug`, `info`, `warn`, `error`, `fatal`.\n\nLogs include the HTTP method, full URL with query parameters, status code, and duration. Request and response data is logged as structured objects.\n\nWhen the log level is `trace` or `debug`, response body data is also included in the output.\n\nClient errors (4xx) are logged as `warn`, server errors (5xx) as `error`.\n\n```\nDEBUG (Todo Api): GET https://dummyjson.com/todos?limit=10\nINFO (Todo Api): GET https://dummyjson.com/todos?limit=10 200 OK (150ms)\nWARN (Todo Api): GET https://dummyjson.com/todos/999 400 Bad Request (100ms)\nERROR (Todo Api): GET https://dummyjson.com/todos 500 Internal Server Error (200ms)\n```\n\n## Signing\n\nSet the `signer` option to automatically sign outgoing requests with an HMAC signature.\n\n```typescript\nimport { LoggerLevels, RequestDataSource } from '@iamnnort/request';\n\nconst dataSource = new RequestDataSource({\n  baseUrl: 'https://api.example.com',\n  logger: {\n    name: 'Webhook Api',\n    level: LoggerLevels.INFO,\n  },\n  signer: {\n    secretKey: 'my-secret-key',\n  },\n});\n```\n\nWhen configured, every request with a body will include an `x-signature` header in the format `t={timestamp},v1={hmac}`, where the HMAC is computed as `SHA-256(secretKey, \"{timestamp}.{body}\")`.\n\nThe header name defaults to `x-signature` and can be customized via `signer.header`.\n\n## Configuration\n\n### Base Config\n\n| Parameter                | Type                     | Description                                                        |\n| ------------------------ | ------------------------ | ------------------------------------------------------------------ |\n| `baseUrl`                | `string`                 | Main part of the server URL that will be used for the request      |\n| `url`                    | `string \\| number`       | Server URL that will be used for the request                       |\n| `urlParts`               | `(string \\| number)[]`   | Additional parts of URL that will be used for the request          |\n| `baseUrlName`            | `string`                 | Key to look up the base URL from `baseUrlMap`                      |\n| `baseUrlMap`             | `Record\u003cstring, string\u003e` | Map of named base URLs                                             |\n| `headers`                | `object`                 | Custom headers to be sent                                          |\n| `auth`                   | `object`                 | HTTP Basic auth credentials                                        |\n| `bearerToken`            | `string`                 | Bearer token for Authorization header                              |\n| `apiKey`                 | `string`                 | API key sent via `x-api-key` header                                |\n| `timeout`                | `number`                 | Request timeout in milliseconds                                    |\n| `responseType`           | `string`                 | Response type (e.g. `json`, `text`, `stream`)                      |\n| `logger`                 | `object`                 | Logger configuration                                               |\n| `logger.name`            | `string`                 | Name used as the logger label                                      |\n| `logger.level`           | `string`                 | Log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`)     |\n| `serializer`             | `object`                 | Config that allows you to customize serializing                    |\n| `serializer.arrayFormat` | `string`                 | Array format (`indices`, `brackets`, `repeat`, `comma`)            |\n| `signer`                 | `object`                 | Request signing configuration                                      |\n| `signer.secretKey`       | `string`                 | HMAC secret key for signing requests                               |\n| `signer.header`          | `string`                 | Header name for the signature (default: `x-signature`)             |\n\n### Request Config\n\n| Parameter    | Type      | Description                                      |\n| ------------ | --------- | ------------------------------------------------ |\n| `params`     | `object`  | URL parameters to be sent with the request       |\n| `data`       | `object`  | Data to be sent as the request body              |\n| `urlencoded` | `boolean` | Send data as `application/x-www-form-urlencoded` |\n| `multipart`  | `boolean` | Send data as `multipart/form-data`               |\n| `xml`        | `boolean` | Send data as `text/xml`                          |\n\n## Methods\n\n| Method       | HTTP Method | Description                                |\n| ------------ | ----------- | ------------------------------------------ |\n| `search`     | `GET`       | Search for entities                        |\n| `searchOne`  | `GET`       | Search for a single entity                 |\n| `bulkSearch` | `GET`       | Paginated search returning async generator |\n| `get`        | `GET`       | Get entity by id                           |\n| `create`     | `POST`      | Create entity                              |\n| `bulkCreate` | `POST`      | Create multiple entities                   |\n| `update`     | `PUT`       | Update entity by id                        |\n| `bulkUpdate` | `PUT`       | Update multiple entities                   |\n| `remove`     | `DELETE`    | Remove entity by id                        |\n| `common`     | any         | Execute a custom request                   |\n\n## License\n\nMIT © [Nikita Pavets](https://github.com/iamnnort)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamnnort%2Frequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamnnort%2Frequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamnnort%2Frequest/lists"}