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

aliyun-function-compat

v1.0.2

Published

aliyun function computing compat

Downloads

6

Readme

Aliyun-function-compat

阿里云函数计算适配器

阿里云的函数计算提供两种入口:普通函数和http函数

普通函数形如event, context, callback

http函数则是req, res, context

本工具包将两种函数转换为event, context模式,并且使用async/await来返回结果

使用方法

安装依赖

npm i aliyun-function-compat

编写代码

const compat = require('aliyun-function-compat')

exports.handler = compat(async (event, context) => {
    await some()

    // 在http模式中,event是req对象,包含queries header等参数,具体看官方文档
    // 本工具接收POST和PUT方法发送的数据,如果是json格式的会对其格式化
    // 否则返回buffer
    // 通过body属性获取
    if(events.method === 'POST') {
        console.log(events.body.id)
    }

    // 可以直接返回错误信息
    throw new Error('some erorr message')

    // 指定错误码
    const err = new Error('error with code')
    err.code = -1234
    throw err

    // 更简单的返回方式
    throw 'error message'

    // 返回处理结果
    return { result:123 }
})