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

apistream-sdk

v1.0.1

Published

[English](README.en.md)

Readme

APIStream SDK

English

这是APISream(基于java的快速私有服务模块部署软件)的配套的js-SDK开发框架,可以帮助开发者快速部署自己的服务模块。

安装

npm install apistream-sdk --save-dev

查看使用

npx apistream --help
# 输出:
#    -d  --deploy                部署
#    -u  --ui                    启动后台监控界面
#    -i  --init                  初始化配置文件
#    -h  --help                  显示帮助信息
#    -r  --remove <project>      删除云端项目

若需要多次使用,推荐 使用 npm exec apistream -h,pnpm apistream -h,或者添加命令到package.json使用, 此文仅用npx用作示例

创建配置文件

以下操作会在当前目录下生成一个名为apistream.config.js的配置文件,请根据实际情况修改其中的配置项。

npx apistream --init

自定义配置文件

import { defineAPIStreamConfig } from 'apistream-sdk'

export default defineAPIStreamConfig({
    projectName: 'myProject', // unique name for your project
    url: 'http://localhost:8080', // your apistream server side service url
    path: 'apistream/src/', // your apistream clound modules' code path
    output: 'src/apistream/', // path for the code that call your apistream clound modules
    key: '', /**
                key to access your apistream server side service,
                it should be the same with the key in your apistream
                server side service "java -jar apistream.jar --key <Key_value>"
            */
    disableOverwrite: true, // if you turn on the overwrite mode,
                            // the apistream will not overwrite the
                            // project that already exists in the server
                            // path, and will throw an error.
})

编写云模块

在你的配置的path目录下创建.js文件或者目录,我们将以每一个文件作为一个上下文隔离的云模块。 每个云模块可以包含多个API函数,普通函数,变量。模块内部可以进行有限次的互相调用。 云模块之间不能相互产生依赖关系。

// 编写云函数,或者云函数使用的工具函数、变量等
export default {
    const :{
        // 这里存放需要放在云端使用的变量,工具函数等只参与模块内的运算的变量
    },
    var: {
        // 这里填写模块配置变量,例如配置模块的并行数量
    }
    // 这里存放需要放在云端并部署的函数
}

如果你只需要导出多个个API函数而不需要其他的变量或配置,你也可以这样导出

export const a = () => {

}

export function b (){

}

使用SQL

我们为您提供了灵活简单的SQL系统调用,示例如下


import { DataBase } from 'apistream-sdk';
export const testfn=()=>{
    console.log(DataBase.selectList('select * from user where id=1'))
}

返回示例:

{
  consoleOutput: '{"sql":"select * from user where id\\u003d1","result":[{"name":"小李","id":1,"age":18,"email":"[email protected]"}]}\n' +
    '1\n',
  result: 'test name'
}

部署云模块

在项目根目录执行以下命令,云函数会自动部署到APIStream软件中,并为您生成对应的调用函数到output目录。

npx apistream -d

使用云函数

output目录下你可以在相同位置找到对应的调用函数,您可以就像调用一个本地函数异步一样调用云模块服务,并传入必要的参数。

相比传统开发模式,我们APIStream自动部署套件可为您节省:

  • 需要多次快速部署的时间
  • 网络请求编写与管理
  • 自动服务日志
  • 序列化/反序列化
  • 后端脚手架搭建
  • 云端接受参数处理
  • 云端接受结果处理

使用示例:

编写一个云模块test.js,并在apistream.config.js中配置pathapistream/src/outputsrc/apistream/

// apistream/src/test.js
const configFn =  () =>{
    return add(3,2)
}
const cloudV = 1
const add = (a,b) => {
    return a+b+cloudV+afterValue
}
const afterValue = 4
export default {
    configFn, // 云函数,可以导出并在本地项目中调用
    const :{
        add, // 云端工具函数,只能在云端使用,本地无法调用
        cloudV, // 云端变量,只能在云端使用,本地无法调用
        afterValue // 云端变量,只能在云端使用,本地无法调用
    },
    var: {
        // 这里填写模块配置变量,例如配置模块的并行数量
        MaxConcurrency: 10, // 最大并发数量
    }
}
// 如果想要获取智能提示,请导入defineModule函数
export default defineModule({
    // 
})

执行以下命令部署云模块:

npx apistream -d

生成的调用函数test.js会自动生成到src/apistream/目录下。

然后你可以在你的项目中导入并调用test.js中的configFn函数。

// src/index.js
import {configFn} from './apistream/test.js'

configFn().then(res => {
    console.log(res.data) // 输出 10
})

启动可视化后台

npx apistream --ui

注意事项

如果可以的话,请保证package.json设置typemodule,以便于使用ES6模块语法和编译检查,尽管它不一定影响运行效果。