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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@timmons-group/snack-pack

v0.1.1

Published

This package contains a collection of components that are used in the Shared Node Architecture Component Kit (SNACK) to serve as scaffolding for building applications.

Readme

Shared Node Architecture Component Kit (SNACK) Pack

This package contains a collection of components that are used in the Shared Node Architecture Component Kit (SNACK) to serve as scaffolding for building applications.

Roadmap

  • [ ] Collect Shared Scaffolding
  • [ ] Refactor
  • [ ] Add Documentation
  • [ ] Publish v1

Scaffold

REST API

We provide helpers for building a rest api via the snack-pack/REST module. This module provides a set of utilities for building a REST API using the snack-pack.

The providers listed below are available:

  • provideDatabase - This will provide a database connection to the supplied funcin using the configuration
  • provideUser - this will call the provided function with the rest request and user object
  • provideErrorHandling - This will wrap the function and return a 500 error if the function throws an error
  • provideRESTDefaults - this provides the database, the user, and the error handling to the function with the supplied permissions

Most often the provideRESTDefaults will be used from this package

import { provideRESTDefaults } from '@timmons-group/snack-pack/REST';

const myHandler = async (apiEvent, databaseDriver, user) => {
  // do something with the request and response
  return {
    statusCode: 200,
    body: 'Hello World!',
  };
};

export const handler = provideRESTDefaults( myHandler, ['read', 'write'] );

This will provide the database connection and user to the function, and will also handle any errors that are thrown. The permissions array will be used to check if the user has the required permissions to access the endpoint. If the user does not have the read or write permissions, a 403 error will be returned.

import { provideDatabase } from '@timmons-group/snack-pack/REST';

const myHandler = async (apiEvent, databaseDriver) => {
  // Here we can run a query against the database
    const result = await databaseDriver.query('SELECT * FROM hello_world');
    return {
        statusCode: 200,
        body: 'Hello ' + result.join(', ') + '!',
    };
};

export const handler = provideDatabase( myHandler );

This will provide the database connection to the function. The databaseDriver will be passed to the function as the second argument. The first argument will be the apiEvent object. This is useful for running queries against the database.

import { provideUser } from '@timmons-group/snack-pack/REST';

const myHandler = async (apiEvent, user) => {
  // Here we can run a query against the database
    
    return {
        statusCode: 200,
        body: 'Hello ' + user.name + '!',
    };
};

export const handler = provideUser( myHandler, myDatabaseDriver );

This will provide the user to the function. The user object will be passed to the function as the second argument. The first argument will be the apiEvent object. This is useful for getting information about the user that is making the request.

import { provideErrorHandling } from '@timmons-group/snack-pack/REST';

const myHandler = async (apiEvent) => {
  // Here we can run a query against the database
    throw new Error('Something went wrong');
};

export const handler = provideErrorHandling( myHandler );

This will provide error handling to the function. If the function throws an error, a 500 error will be returned. The error message will be logged to the console. This is useful for handling errors that occur in the function.

REST Endpoint Builder

The RESTEndpointBuilder is a utility that allows you to build a REST endpoint using the snack-pack/REST module. This is useful for building a REST API using the snack-pack without having to manually provide the database, user, and error handling to the function.

Long form example of using the RESTEndpointBuilder to build a REST endpoint:


import { RESTEndpointBuilder } from '@timmons-group/snack-pack/REST/Endpoints';

const internalHandlerFunction = async (apiEvent, {databaseDriver, user}) => {
  // do something with the request and response
  return {
    statusCode: 200,
    body: 'Hello World!',
  };
};

export const handler = new RESTEndpointBuilder(internalHandlerFunction)
    .withDatabase()
    .withUser()
    .withErrorHandling()
    .withPermissions(['read', 'write'])
    .build();
    

Short form example of using the RESTEndpointBuilder to build a REST endpoint:


import { RESTEndpointBuilder } from '@timmons-group/snack-pack/REST/Endpoints';

const internalHandlerFunction = async (apiEvent, {databaseDriver, user}) => {
  // do something with the request and response
  return {
    statusCode: 200,
    body: 'Hello World!',
  };
};

export const handler = new RESTEndpointBuilder(internalHandlerFunction)
    .withRESTDefaults(['read', 'write'])
    .build();
    

Auth

Using the provided oAuth endpoints as follows

import { handler as oAuthHandler } from '@timmons-group/snack-pack/Auth/Endpoints'

export const handler = oAuthHandler;