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

buttonize

v1.8.1

Published

<p align="center"> <a href="https://buttonize.io"> <img width="350" alt="Buttonize.io" src="https://user-images.githubusercontent.com/6282843/212024942-9fd50774-ea26-48ba-b2cf-ca2584498c9a.png"> </a> </p>

Downloads

125

Readme


Buttonize enables you to build internals tools with AWS CDK.

Hook-up UI components directly to AWS Lambda functions. Just install Buttonize and deploy your CDK. That's it.

Getting started

Sign-up at app.buttonize.io

Setup fresh new CDK project

npm

$ npx create-buttonize
$ cd my-buttonize-app && npm install
$ npx buttonize dev --profile=YOUR_AWS_PROFILE bin/cdk.ts

pnpm

$ pnpm create buttonize
$ cd my-buttonize-app && pnpm install
$ pnpm buttonize dev --profile=YOUR_AWS_PROFILE bin/cdk.ts

Install to existing CDK project

Modify CDK bin code to export the App

export const app = new cdk.App()

npm

$ npm install -D buttonize
$ npx buttonize dev --profile=YOUR_AWS_PROFILE bin/cdk.ts

pnpm

$ pnpm add -D buttonize
$ pnpm buttonize dev --profile=YOUR_AWS_PROFILE bin/cdk.ts

Constructs Library

With Buttonize you have two options how to build your internal apps

  1. Build your own custom app by using ButtonizeApp construct. Learn more in the next section.
  2. Use Constructs Library with ready-made customizable constructs for different AWS services.

Learn more about library.

Constructs Library

Build your own Buttonize app

.
├── bin
│   └── cdk.ts
├── lib
│   └── example-stack.ts
├── src
│   └── discountGenerator.ts
├── cdk.json
└── package.json
// bin/cdk.ts

#!/usr/bin/env node
import 'source-map-support/register'

import * as cdk from 'aws-cdk-lib'

import { ExampleStack } from '../lib/example-stack'

export const app = new cdk.App()
new ExampleStack(app, 'ExampleStack')
// lib/example-stack.ts

import * as cdk from 'aws-cdk-lib'
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'
import { Action, Buttonize, ButtonizeApp, Display, Input } from 'buttonize/cdk'
import { Construct } from 'constructs'
import * as path from 'path'

export class ExampleStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props)

    Buttonize.init(this, {
      apiKey: 'btnz_mybuttonizekey1234567'
    })

    const discountGenerator = new NodejsFunction(this, 'DiscountGenerator', {
      entry: path.join(__dirname, '../', 'src', 'discountGenerator.ts')
    })

    new ButtonizeApp(this, 'DemoApp', {
      name: 'Discount code generator',
      description:
        'Select the discount amount and you will get the discount code on the next page.'
    })
      .page('InputPage', {
        body: [
          Display.heading('Generate discount code for customer'),
          Input.select({
            id: 'discount',
            label: 'Discount value',
            options: [
              { label: '30%', value: 30 },
              { label: '60%', value: 60 }
            ]
          }),
          Display.button({
            label: 'Generate discount',
            onClick: Action.aws.lambda.invoke(
              discountGenerator,
              { Payload: { discountValue: '{{discount}}' } },
              { id: 'discountGenerator' }
            ),
            onClickFinished: Action.buttonize.app.changePage('DonePage')
          })
        ]
      })
      .page('DonePage', {
        body: [
          Display.heading('Discount generated'),
          Display.text('Discount code: {{InputPage.discountGenerator.code}}')
        ]
      })
  }
}
// src/discountGenerator.ts

export const handler = async (event: { discountValue: number }) => {
  console.log(`Generating discount of value ${event.discountValue}`)

  return {
    discountValue: event.discountValue,
    code: `${Math.random()}`.split('.')[1]
  }
}

Result


CLI

Options

--profile

AWS profile name to used for fetching stack metadata. You can also set AWS_PROFILE environment variable instead.

$ npx buttonize dev --profile=YOUR_AWS_PROFILE bin/cdk.ts

--region

AWS region used for fetching stack metadata. You can also set AWS_REGION environment variable instead.

$ npx buttonize dev --region=eu-central-1 bin/cdk.ts

--help

Prints out CLI help information.

$ npx buttonize --help

Arguments

<entrypoint>

Path to JS/TS file where the CDK app is defined.

$ npx buttonize dev bin/cdk.ts

Docs

Learn more at docs.buttonize.io


Join our community Discord | Twitter