npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

coding-picbed

v0.0.13

Published

Upload file to coding repository and Get Url

Readme

Coding 图床

基于 Coding 企业版仓库的图床。通过『静态网站』或公开源代码的方式获得外链链接。使用 Coding 个人令牌 API 上传图像。

安装

npm install coding-picbed

用法

const coding = require('coding-picbed')({
    token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    repository: 'https://imlinhanchao.coding.net/imlinhanchao/upload-file'
});
const path = require('path');
const fs = require('fs');

router.post('/upload', async (req, res, next) => {
    let data = req.files[0].buffer;
    let filename = req.files[0].originalname;
    let filepath = path.join(__dirname, filename);

    fs.writeFileSync(filepath, data)
    let upload = await coding.upload(filepath, '/', filename);
    fs.unlinkSync(filepath);

    res.json(upload);
})

或者

const { Coding } = require('coding-picbed');
const path = require('path');
const fs = require('fs');

router.post('/upload', async (req, res, next) => {

    let coding = new Coding();
    await coding.config({
        token: req.query.token,
        repository: req.query.repo
    });

    let data = req.files[0].buffer;
    let filename = req.files[0].originalname;
    let filepath = path.join(__dirname, filename);

    fs.writeFileSync(filepath, data)
    let upload = await coding.upload(filepath, '/', filename);
    fs.unlinkSync(filepath);

    res.json(upload);
})

准备

  1. 您需要在个人设置访问令牌中创建访问令牌. 只需要开放 project|project:depot|project:file 权限即可。 ~~2. 创建用于上传文件的存储库,开通『构建与部署』中静态网站服务或公开仓库源代码。~~

函数

配置上传选项

async function config({ token, repository });

参数对象

|键|描述| |--|--| |token|你创建的 Coding 访问令牌。| |repository|你的用于上传文件存储库地址。|

检查初始化状态

async function isInitialized();

返回值

bool - true 表示完成初始化。

上传文件

async function upload(filepath, dir, filename);

参数对象

|键|描述| |--|--| |filepath|您要上传的文件路径。| |dir|你要保存到仓库的文件夹,若不存在会自动创建。(可选)| |filename|你要保存到仓库的文件名。(可选)|

返回值

|键|描述| |--|--| |filename|最终上传的文件名。| |urls|所有可用的 Web 访问地址。|

注意事项

配置 Coding 存储库地址和访问令牌后,大约需要几秒钟来获取 Coding 仓库的信息。因此,请不要在配置后立即上传。你可以使用 isInitialized 检查初始化是否已完成,或者使用 await 等待配置完成。