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 🙏

© 2024 – Pkg Stats / Ryan Hefner

coding-sdk

v3.0.2

Published

Open API SDK for Coding.net

Downloads

22

Readme

Coding SDK

github npm npm codecov Travis-CI codebeat badge

已经疯狂得不能用代码行数(总计56行,包含空行和debug)来衡量该项目了,代码仅有 1,375字节(净化后)。

五十六个民族五十六朵花。啦啦啦~

[TOC]

安装

yarn add coding-sdk
# or npm i -S coding-sdk

本项目中使用 camelCase 驼峰命名法则。

Scope 说明

scope 参数应传入数组如: ['user', 'project', 'team']

scope 名称 | 说明 | 授权 :--| -- | :--: user | 授权获取用户信息(用户名称,头像,tag,email,动态 ) | 读 user:email | 授权获取用户的email ) | 读 notification | 授权读取通知信息,包含email通知 | 读写 social | 授权读取冒泡列表,好友列表 | 读 social:tweet | 授权发送冒泡,冒泡操作(点赞、评论、删除) | 读写 social:message | 授权读取、发送私信、私信语音 | 读写 project | 授权项目信息、项目列表,仓库信息,公钥列表、成员,任务列表 | 读 project:members | 授权项目管理者增、删、改项目成员,退出项目 | 读写 project:task | 授权任务操作,包含增、删、改 | 读写 project:file | 授权文件,包含增、删、改 | 读写 project:depot | 获取 commit 信息,分支操作,MR/PR, LineNotes, fork, webhook 等操作 | 读写 project:key | 授权操作部署公钥、个人公钥 | 读写 team | 获取团队相关基本信息 | 读

Oauth 使用 示例

const SDK = require('coding-sdk');
// 初始化实例:
const coding = new SDK({
  clientId: 'xxx',
  clientSecret: 'xxx',
  callback: 'http://localhost/coding/callback'
});

// 获取 OAuth 鉴权链接 URL
console.log(coding.url());
// 如: https://coding.net/oauth_authorize.html?client_id=xxx&redirect_uri=xxx&response_type=code&scope=user
// 登录后跳转回 callback URL,获取其中的 code 字段

// 注意包裹在 async 内, 或者用 Promise.then(res=>{ console.log(res.data) }) 来获取返回 json 结果
const { data } = await coding.get('oauth/access_token', {
  grant_type: 'authorization_code',
  code: 'xxxxxx'
});
/*
{ access_token: 'xxxxx',
  refresh_token: 'xxxxx',
  expires_in: '864000' }
*/

Token 使用 示例

const coding = new SDK({
  user: 'willin',
  token: 'xxxxxx'
});

const { data } = await coding.delete('user/XXX/project/XXX/task/XXX');
/*
{ code: 0, data: true }
*/

一些公开接口 使用 示例

const coding = new SDK();

const { data } = await coding.get('user/key/willin')
/*
{
  code: 0,
  data: { ... }
}
*/

补充示例

获取 OAuth 登录地址

coding.url();

获取 access_token

const data = await coding.get('oauth/access_token', {
  grantType: 'authorization_code',
  code: 'xxxxxx'
}).then(res=>res.data);
/*
返回数据格式:
{
  access_token: "xxxxxxx",
  refresh_token: "xxxxxx",
  expires_in: "86382817"
}
*/

License

Apache 2.0

通过支付宝捐赠:

qr