@cimo/request

中文文档
1.7.52发布于 2026/10/14MITTypeScriptES Module零依赖近 30 天下载 4881

Request api. Light, fast and secure.

原始使用文档
文档目录5 节
  1. Pack
  2. Publish
  3. Installation
  4. Reset
  5. Client

Npm_request

Npm package, request api. Light, fast and secure. Writed with native Typescript code and no dependencies are used.

Pack

  1. npm run build
  2. Copy the file "/build/package_name-x.x.x.tgz" in the project root folder.
  3. In the "package.json" file insert: "@cimo/package_name": "file:package_name-x.x.x.tgz"

Publish

  1. npm run build
  2. npm login --auth-type=legacy
  3. npm publish --auth-type=legacy --access public

Installation

  1. Link for npm package -> https://www.npmjs.com/package/@cimo/request

Reset

  1. Delete this from the root:
    • dist
    • node_modules
    • package-lock.json

Client

  • Client.ts
...

import { Cr } from "@cimo/request/dist/src/Main";

...

const cr = new Cr("https://localhost");

cr.setRequestInterceptor((config) => {
    //...

    return {
        ...config,
        headers: {
            ...config.headers,
            "Accept-Language": "en,ja;q=0.9"
        }
    };
});

cr.setResponseInterceptor((response) => {
    // ...

    if (response.ok) {
        // Success
    } else {
        // Fail
    }

    return response;
});

...

const data = {
    token_api: "abc123",
    name: "test",
};

cr.post("/test_post_json",
        {
            headers: {
                "Content-Type": "application/json"
            }
        },
        data
    )
    .then((data) => {
        // Response
    })
    .catch((error: Error) => {
        // Error
    });

...

const formData = new FormData();
formData.append("token_api", "abc123");
formData.append("name", "test");
// In case of file upload, just delete the headers content-type parameter.

cr.post("/test_post_form-data",
        {
            headers: {
                "Content-Type": "multipart/form-data"
            }
        },
        formData
    )
    .then((data) => {
        // Response
    })
    .catch((error: Error) => {
        // Error
    });

...

cr.get("/test_get", {})
    .then((data) => {
        // Response
    })
    .catch((error: Error) => {
        if (error.cause === 401) {
            // Unauthorized
        }
    });

// put, delete, patch

...

const data = {
    name: "test",
};

cr.stream("/test_stream",
        {
            headers: {
                "Content-Type": "application/json"
            }
        },
        data
    )
    .then(async (reader) => {
        const decoder = new TextDecoder("utf-8");
        let buffer = "";

        while (true) {
            const { value, done } = await reader.read();

            ...

            buffer += decoder.decode(value, { stream: true });
            const lineList = buffer.split(/\r?\n/);
            buffer = lineList.pop() as string;

            ...
        }
    });

...

版本与发布记录

@cimo/request 共发布 57 个版本,首次发布于 2023/10/12;过去 12 个月发布了 30 个版本。

版本发布日期距今
1.7.52latest2026/10/1426 天前
1.7.512026/10/081 个月前
1.7.502026/09/171 个月前
1.7.492026/08/063 个月前
1.7.482026/06/254 个月前
1.7.472026/06/085 个月前

关于 @cimo/request 的常见问题

@cimo/request 是什么?

Request api. Light, fast and secure.

如何安装 @cimo/request?

在项目目录运行 npm install @cimo/request,或使用 pnpm add / yarn add / bun add。

@cimo/request 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cimo/request 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cimo/request 可以商用吗?

@cimo/request 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cimo/request 的下载量有多少?

根据 npm 官方下载统计,@cimo/request 在 2026/10/10 – 2026/11/08 这 30 天内被下载 4,881 次,日均约 163 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cimo/request 还在维护吗?

最新版本 1.7.52 发布于 2026/10/14(26 天前);至今共发布 57 个版本,其中过去 12 个月发布了 30 个;首次发布于 2023/10/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。