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

@mincloudx/faas

v0.4.0

Published

A more user-friendly Node.js cloud function development framework.

Downloads

10

Readme

@mincloudx/faas

Version TypeScript

A more user-friendly Node.js cloud function development framework, designed to simplify interactions with Backend-as-a-Service (BaaS) and ensure consistent response structures.

Features

  • Default Parameter Handling: Automatically transforms null or missing event.data into an empty object, ensuring your function always receives a valid event object.
  • Unified Return Format: Standardizes the return format of cloud functions. Non-object returns are wrapped as {data: value}, while object returns are passed through as-is.
  • BaaS SDK Version Management: By default, uses the latest SDK version available but allows for explicit version setting or opting out of version updates.

Usage

Installation

pnpm install @mincloudx/faas

Creating a Cloud Function

In your cloud function file, import and use createFaas to wrap your main function. This not only standardizes the behavior of your cloud function but also handles BaaS SDK version management and event data preprocessing.

import { createFaas, FAAS_LATEST_SDK_VERSION } from '@mincloudx/faas';

async function main(event) {
  // Your function logic here
  console.log(`event:`, event);

  return { status: 'ok' };
}

export default createFaas(main, {
  updateVersion: true, // Optional: Ensures the BaaS SDK is always up-to-date. Default is true.
  version: 'specific-version', // Optional: Set a specific BaaS SDK version if required.
});

Test

Ensure the reliability and correctness of your functions by testing with Jest. The framework provides a streamlined way to test various scenarios, such as default parameter handling, unified return format, and BaaS SDK version management.

pnpm run test

Development

Compiling TypeScript

Prepare your package for use by compiling TypeScript files.

pnpm run tsc

Watch Mode

Automatically recompile TypeScript files upon changes for efficient development.

pnpm run watch

This improved README incorporates details from the test cases, emphasizing the utility and flexibility of createFaas. It clarifies how users can manage BaaS SDK versions and the behavior of cloud functions with respect to input and return values, providing a comprehensive guide for both usage and development.