{"id":15504473,"url":"https://github.com/kwonoj/oxid","last_synced_at":"2025-07-24T21:04:51.677Z","repository":{"id":57317311,"uuid":"148267128","full_name":"kwonoj/oxid","owner":"kwonoj","description":"rxjs observable based isomorphic http request module.","archived":false,"fork":false,"pushed_at":"2018-11-25T21:54:59.000Z","size":616,"stargazers_count":14,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T00:14:41.642Z","etag":null,"topics":["ajax","async","http","observable","rxjs","xhr","xmlhttprequest"],"latest_commit_sha":null,"homepage":"","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/kwonoj.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-11T05:51:36.000Z","updated_at":"2023-11-07T12:49:38.000Z","dependencies_parsed_at":"2022-08-25T21:11:47.896Z","dependency_job_id":null,"html_url":"https://github.com/kwonoj/oxid","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Foxid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Foxid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Foxid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Foxid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kwonoj","download_url":"https://codeload.github.com/kwonoj/oxid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250343948,"owners_count":21415040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","async","http","observable","rxjs","xhr","xmlhttprequest"],"created_at":"2024-10-02T09:18:15.443Z","updated_at":"2025-04-23T00:10:40.902Z","avatar_url":"https://github.com/kwonoj.png","language":"TypeScript","readme":"[![Package version](https://badgen.net/npm/v/oxid)](https://www.npmjs.com/package/oxid)\n[![Build Status](https://ojkwon.visualstudio.com/oxid/_apis/build/status/kwonoj.oxid?branchName=master)](https://ojkwon.visualstudio.com/oxid/_build/latest?definitionId=1)\n[![Coverage](https://badgen.net/codecov/c/github/kwonoj/oxid)](https://codecov.io/gh/kwonoj/oxid/branch/master)\n[![Node engine version](https://badgen.net/npm/node/oxid)](https://www.npmjs.com/package/oxid)\n[![Minified, zipped size](https://badgen.net/bundlephobia/minzip/oxid)](https://badgen.net/bundlephobia/minzip/oxid)\n\n# Oxid\n\n`oxid` is [rxjs observable](https://github.com/ReactiveX/rxjs) based isomorphic http request module.\n\n## Install\n\nThis has a peer dependencies of `rxjs@6`, which will have to be installed as well\n\n```sh\nnpm install oxid\n```\n\n## Usage\n\nOxid exports default instance `oxid`, also exposes `Oxid` class to construct separate instances.\n\n```ts\nimport { oxid, Oxid } from 'oxid';\n\noxid.get('url', options).subscribe();\n\nconst anotherInstance = new Oxid(customConfigurations);\nanotherInstance.get('url', options).subscribe();\n```\n\nAll of oxid's interface returns `Observable\u003cHttpEvent\u003cT\u003e\u003e` allows to subscribe into from base `request` function to http method function.\n\n```ts\ntype requestMethodType = \u003cT\u003e(url: string, config?: RequestConfig) =\u003e Observable\u003cHttpEvent\u003cT\u003e\u003e;\ntype requestMethodWithDataType = \u003cT, U\u003e(url: string, data?: T, config?: RequestConfig) =\u003e Observable\u003cHttpEvent\u003cU\u003e\u003e;\n\n\nclass Oxid {\n  public readonly delete: requestMethodType;\n  public readonly get: requestMethodType;\n  public readonly head: requestMethodType;\n  public readonly options: requestMethodType;\n\n\n  public readonly post: requestMethodWithDataType;\n  public readonly put: requestMethodWithDataType;\n  public readonly patch: requestMethodWithDataType;\n\n  public request\u003cT extends object | string = any\u003e(url: string, config?: RequestConfig): Observable\u003cHttpEvent\u003cT\u003e\u003e;\n  public request\u003cT extends object | string = any\u003e(url: string): Observable\u003cHttpEvent\u003cT\u003e\u003e;\n  public request\u003cT extends object | string = any\u003e(config: RequestConfig): Observable\u003cHttpEvent\u003cT\u003e\u003e;\n  public request\u003cT extends object | string = any\u003e(\n    urlOrConfig: RequestConfig | string,\n    config?: RequestConfig\n  ): Observable\u003cHttpEvent\u003cT\u003e\u003e {\n```\n\n### Configure oxid\nOxid includes default set of configuration values. This value will be used when use request instance `oxid`. When creating new instance via class, it doesn't include any option values by default, have to specify via class constructor. Still, individual method (`request()` and rest) accepts `RequestConfig` separately, which will merge into configurations when instance is being created.\n\n```ts\ninterface RequestConfigBase {\n  url?: string;\n  method?: Method;\n  baseURL?: string;\n  transformRequest?: Transformer | Array\u003cTransformer\u003e;\n  transformResponse?: Transformer | Array\u003cTransformer\u003e;\n  headers?: any;\n  params?: any;\n  paramsSerializer?: (params: any) =\u003e string;\n  data?: any;\n  adapter?: Adapter;\n  auth?: BasicCredentials;\n  responseType?: ResponseType;\n  responseEncoding?: string;\n  xsrfCookieName?: string;\n  xsrfHeaderName?: string;\n  maxContentLength?: number;\n  validateStatus?: (status: number) =\u003e boolean;\n  maxRedirects?: number;\n  socketPath?: string | null;\n  proxy?: ProxyConfig;\n}\n\n\ninterface RequestConfigNode extends RequestConfigBase {\n  /**\n   * Custom agent to be used in node http request.\n   */\n  httpAgent?: any;\n  /**\n   * Custom agent to be used in node https request.\n   */\n  httpsAgent?: any;\n  transport?: { request: typeof import('http').request };\n}\n\n\ninterface RequestConfigBrowser extends RequestConfigBase {\n  /**\n   * Emit progress event for xhr request.\n   */\n  reportProgress?: boolean;\n  withCredentials?: boolean;\n}\n```\n\n```ts\nimport {oxid, Oxid, defaultOptions} from 'oxid';\n\noxid.get(url); //will use `defaultOptions`\noxid.get({url, withCredentials: false}); //will use `defaultOptions`, override `withCredentials`\n\nconst another = new Oxid(); //no base configueration\nconst anotherWithConfig = new oxid({withCredendials: false}) //set base configuration\n\nanotherWithConfig.get({url, withCredentials: false}) //will use config when instance created, override `withCredentials`\n```\n\nNote `defaultOptions` object is immutable. Changing, reassigning values into existing default configuration value won't work, instead should build new configuration object.\n\n## Debugging internals of oxid\n\nOxid itself doesn't have mechanism to write log. Instead, it exposes a function to wire any logger used in application.\n\n```ts\nfunction enableLogger(logger: logFunctionType): void;\nfunction enableLogger(logger: Partial\u003cLogger\u003e): void;\n```\n\nIt could be either single function, or object have loglevels like debug, info, warn, error. Notes `enableLogger` is **Global function** to affects any instance of oxid, and only starts emitting log once after `enableLogger` has been called.\n\n```ts\nimport { enableLogger, oxid } from 'oxid';\n\n// logs are not emitted\noxid.get().subscribe();\n\nenableLogger(console.log.bind(console));\n\n// now internal logs will be emitted via console\noxid.get().subscribe();\n```\n\n## Building / Testing\n\nFew npm scripts are supported for build / test code.\n\n- `build`: Transpiles code to `dist`.\n- `build:clean`: Clean up existing build.\n- `test`: Run unit test. Does not require `build` before execute test.\n- `lint`: Run lint over all codebases.\n\n## Credits\n\nWhile this module is **NOT** officially affiliated, it relies on lot of prior art from [`axios`](https://github.com/axios/axios) and [`@angular/http`](https://github.com/angular/angular/tree/master/packages/common/http). You may notice some similar logics and it is expected.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwonoj%2Foxid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkwonoj%2Foxid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwonoj%2Foxid/lists"}