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

@smartsheet-extensions/handler

v1.1.5

Published

Library to help build entry points for Smartsheet extensions.

Downloads

14

Readme

Extension Handler

Library to help build entry points for Smartsheet extensions.

This library is NOT intended to be used directly but instead by other libraries.

Quick Start

This library exports a function called createExtensionHandler that takes a series of "enhancers" and returns a function that should be exported as the entry point to a Smartsheet extension.

export const main = createExtensionHandler(
  ...middleware // Middleware enhancers go here.
);

Usage

Enhancers can be used to enhance the functionality of the main handler. In most cases this is used to apply middleware to the flow of data or to modify the handler for use with other transports.

export const main = createExtensionHandler(httpTransport, handlePromises);

This will export a function that:

  • Takes a Request object and a Response object
  • Execute the handler
  • Resolve any returned promises
  • And send a 200 response with the value from the resolved promise.

Enhancers

The handler by itself can't do much, but enhancers can be used to extend the functionality of the handler from defining the transport interface to applying middleware and handling business logic. The library comes with some useful enhancers built in.

httpTransport

This enhancer will return a function that takes a Request and a Response and passes the body parameter from the request through to the handler (or next enhancer). Any response from the handler is converted to json and returned on the response with a 200 status.

Note: Should always be the first enhancer given and shouldn't be used with any other transport enhancers.

handleHasProperty

This handler will throw BadRequestError if a given property does not exist on the payload.

return createExtensibleHandler(handleHasProperty('abc'));
// Pass
{ "abc": 'Hello, World!' };
// Fail
{ "notAbc": 'Hello, World!' };

handlePing

This handler will immediately return if the payload includes a property called event and it is equal to PING.

Note: This is an internal health check device and should always be included.

handlePromises

This handler will take a returned Promise and wait for it to resolve before returning the resolved data.

// index.js
return createExtensibleHandler(handlePromises);

// handler.js
return () =>
  new Promise(resolve => {
    setTimeout(() => {
      resolve('Hello,World!');
    }, 1000);
  });

handleThunks

This handler will call a returned function with the callback as a parameter allowing handlers greater control of when to respond to the caller.

// index.js
return createExtensibleHandler(handleThunks);

// handler.js
return () => respond => {
  // execute before handler responds
  respond();
  // execute after handler responds
};