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

@architect/plugin-lambda-invoker

v2.0.1

Published

Interactively invoke Lambdas in Architect Sandbox with arbitrary events

Downloads

3,182

Readme

@architect/plugin-lambda-invoker

Interactively invoke Lambdas in Architect Sandbox with arbitrary events

GitHub CI status

Install

Into your existing Architect project:

npm i @architect/plugin-lambda-invoker --save-dev

Add the following to your Architect project manifest (usually app.arc):

@plugins
architect/plugin-lambda-invoker

Usage

CLI

While Sandbox is running, type i in your terminal to bring up the Lambda invocation menu. Then select the Lambda you'd like to invoke.

By default, this plugin will populate your menu with all @events, @queues, @scheduled, and @tables-streams; you can limit this menu (or expand it with additional pragmas) by adding the following setting to a pref[erence]s.arc file:

@sandbox
invoker http scheduled # This would populate @http + @scheduled Lambdas, and ignore all others

Tip: you can navigate the invocation menu by typing numbers (zero-indexed)!

Programmatic

The plugin also passes through the Sandbox invoker for programmatic use (such as in a test environment). This method is only available after Sandbox has finished initializing.

let sandbox = require('@architect/sandbox')
let invokerPlugin = require('@architect/plugin-lambda-invoker')

await sandbox.start()
await invokerPlugin.invoke({
  pragma: 'scheduled',
  name: 'my-scheduled-event',
  payload: { ok: true },
})
await sandbox.end()

Invocation mocks

By default, Lambdas are invoked with an empty payload ({}); if you'd like to invoke your Lambdas with arbitrary payloads, create a file containing invocation mocks.

Invocation mock files live in your root with one of these filenames: sandbox-invoke-mocks.json or sandbox-invoke-mocks.js. These files should be structured like so:

Assuming this project manifest:

@events
background-task

@queues
analytics

@scheduled
backup-database

@tables-streams
tableName

If you wanted to add one or more mocks to each of the three Lambdas above, create the following sandbox-invoke-mocks.js (or equivalent JSON) file with the format of [pragmaName][lambdaName][mockName]:

module.exports = {
  events: {
    'background-task': {
      'my-first-mock': { /* payload */ },
      'another-mock': { /* payload */ },
    }
  },
  queues: {
    analytics: {
      'one-more-mock': { /* payload */ },
      'just-a-mock': { /* payload */ },
    }
  },
  scheduled: {
    'backup-database': {
      'a-mock-for-this': { /* payload */ },
      'the-last-mock': { /* payload */ },
    }
  },
  'tables-streams':{
    tableName:{
      INSERT:{ /* payload */ },
      MODIFY:{ /* payload */ },
      REMOVE:{ /* payload */ },
    }
  }
}

Tip: when using sandbox-invoke-mocks.js, you can dynamically (synchronously) generate mocks on startup