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

suanpan_node_sdk_test

v1.2.3

Published

suanpan sdk for node.js

Downloads

3

Readme

JavaScript Style Guide

简介

目前 node.js sdk

  • 支持消息收发
  • 读取组件的右面板参数
  • 支持 oss 类型的 storage 功能[beta]

安装 sdk

npm install suanpan_node_sdk

Docker

可以使用基础镜像 node_sdk_base:latest latest可替换为指定的SDK版本号 例如

ARG ARCH="amd64"
FROM registry.cn-shanghai.aliyuncs.com/shuzhi-$ARCH/node_sdk_base:latest

基础镜像中 suanpan_node_sdk 通过全局安装 本地开发可以通过npm install -D suanpan_node_sdk来提供代码提示

API 列表

加载 sdk

let sp = require('suanpan_node_sdk').sp

获得右面板配置参数(parameter)

let spParameter = sp.parameter
console.log(spParameter)

发送消息与接受消息

构建发送包

let msgPackOut={
    out1:"a", //将发送 "a" 到第一个消息出口
    out2:"b", //将发送 "b" 到第二个消息出口
    // key(outN) 表示第N个消息出口, value必须是字符串
}

监听 call 事件

// 当由一个消息到达时候触发
sp.onCall((req, res) => {
    let msgPackIn = req.msg
    console.log(msgPackIn)
    // msgPackIn结构如下
    //{in1:"a"}
    // key(inN) 表示第N个消息入口, value是字符串
    // doSomething here
    res.send(msgPackOut)
})

主动发送信息

sp.sendMessage(msgPack)

存储相关

目前存储相关api仍处于beta状态,api接口会活跃变动

let storage = require("suanpan_node_sdk").sp.storage; // use node module
if (1) {
  async function test() {
    if (1) {
      console.log("now we list all synced files");
      let list_result = await storage.list("/");
      console.log("list_result", list_result);
    }
    if (1) {
      console.log("now we upload **package.json** as new.json");
      let upload_result = await storage.upload("./package.json", "new.json");
      console.log("upload successfully:", upload_result);
    }
    if (1) {
      console.log("now we list, should see **new.json**");
      let list_result = await storage.list("/");
      console.log("list_result", list_result);
    }
    if (1) {
      console.log(
        "now we download **new.json** to local with new name **download.json**"
      );
      let download_file_buffer = await storage.download("new.json");
      let fs = require("fs");
      console.log("download_file_buffer type:", typeof download_file_buffer);
      console.log(
        "download_file_buffer isBuffer:",
        Buffer.isBuffer(download_file_buffer)
      );
      fs.writeFileSync("./download.json", download_file_buffer);
    }
    if (1) {
      console.log(
        "now we download **new.json** direct to local file **download2.json**"
      );
      await storage.download("new.json", "./download2.json");
      // console.log('is_download_success:', is_download_success)
    }

    if (1) {
      console.log("now we delete  **new.json**");
      let r = await storage.delete("new.json");
    }
    if (1) {
      console.log("now we list, should see **new.json** disappear");
      let list_result = await storage.list("/");
      console.log("list_result", list_result);
    }
    console.log("now we exit all test done");
    process.exit();
  }
  test();
}

static 原则 图片资源 html等前端资源