{"id":15408349,"url":"https://github.com/yusukebe/xc","last_synced_at":"2025-04-18T16:12:03.765Z","repository":{"id":64999935,"uuid":"580584576","full_name":"yusukebe/xc","owner":"yusukebe","description":"Express-like HTTP Client","archived":false,"fork":false,"pushed_at":"2022-12-21T01:11:59.000Z","size":117,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-08T17:09:02.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/xcjs","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusukebe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-20T23:26:06.000Z","updated_at":"2024-04-24T00:37:09.000Z","dependencies_parsed_at":"2022-12-31T06:58:38.819Z","dependency_job_id":null,"html_url":"https://github.com/yusukebe/xc","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fxc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fxc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fxc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fxc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusukebe","download_url":"https://codeload.github.com/yusukebe/xc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233558615,"owners_count":18694078,"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":[],"created_at":"2024-10-01T16:33:36.459Z","updated_at":"2025-01-12T02:36:10.074Z","avatar_url":"https://github.com/yusukebe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Xc - Express-like HTTP Client\n\nXc is a HTTP Client based on Fetch API which you can write with the Express-like syntax.\n\n```ts\nimport { Xc } from 'xcjs'\n\nconst client = new Xc('https://ramen-api.dev/')\n\nconst json = await client\n  .get('/shops/:shopId', (c) =\u003e {\n    c.header('User-Agent', 'Xc')\n    c.param('shopId', 'yoshimuraya')\n  })\n  .json\u003c{ shop: { name: string } }\u003e()\n\nconsole.log(`You may like ${json.shop.name}`)\n```\n\nOr you can write shortly.\n\n```ts\nimport { xc } from 'xcjs'\n\nconst json = await xc.get('https://ramen-api.dev/').json()\n```\n\n## Install\n\n```\nnpm i xcjs\n```\n\nOr\n\n```\nyarn add xcjs\n```\n\n## Example\n\n```ts\n// Create an instance\nconst client = new Xc('https://httpbin.org')\n\n// GET request with query params\nconst json = await client\n  .get('/get', (c) =\u003e {\n    c.query('page', '2')\n    c.query('perPage', '10')\n  })\n  .json()\n\n// POST request with JSON body\nconst text = await client\n  .post('/post', (c) =\u003e {\n    c.json({\n      title: 'Hello!',\n      body: 'I like a ramen.',\n    })\n  })\n  .text()\n\n// Or you can write shortly\nawait client.post('/post', {\n  title: 'Hello!',\n  body: 'I like a ramen.',\n})\n\n// PUT form data\nconst res = await client.put('/put', (c) =\u003e {\n  c.body({\n    id: '123',\n    name: 'Xc',\n  })\n})\n\n// Hook\nconst json = await xc\n  .hook((res) =\u003e {\n    if (res.status === 404) {\n      return { error: 'No Ramen!' }\n    }\n  })\n  .get('https://ramen-api.dev/not-found')\n  .json()\n\nconsole.log(json) // { error: 'No Ramen!' }\n```\n\n## Related Projects\n\n- Express - \u003chttps://expressjs.com\u003e\n- Ky - \u003chttps://github.com/sindresorhus/ky\u003e\n- Ramen API - \u003chttps://github.com/yusukebe/ramen-api\u003e\n\n## Author\n\nYusuke Wada \u003chttps://github.com/yusukebe\u003e\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fxc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusukebe%2Fxc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fxc/lists"}