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

concise-constructs

v0.0.2

Published

A functional-feeling DX for the AWS CDK and other construct libraries

Downloads

7

Readme

Concise Constructs

npm version license PRs welcome

A utility for defining constructs without ever needing to think about scope. "Concise" constructs are interoperable with classical constructs. The difference is cosmetic; if concise constructs better-jive with your API-design sensibilities, great! Otherwise, classical constructs are still state of the art.

NOTE: this repo follows SemVer and there is yet to be a major release; the public API can still change.

NOTE: JSII cannot yet package concise constructs for consumption in non-TypeScript CDK projects.


Resources

To execute an example, run npm run example [example-dir] [command] (for example, npm run example graphql-api deploy)

Installation

Node users can install with npm.

npm install concise-constructs

Packaged as CommonJS, alongside corresponding type definitions.

Snippets

Lambda Rest API

import {C} from "concise-constructs";
import * as cdk from "@aws-cdk/core";
import * as lambda from "@aws-cdk/aws-lambda";
import path from "path";

const code = new lambda.AssetCode(path.resolve(__dirname, "lambda"));

const Stack = C(cdk.Stack, (define) => ({
  fn: define`my-fn`(lambda.Function, {
    code,
    handler: "index.handler",
    runtime: lambda.Runtime.NODEJS_12_X,
  }),
}));

const App = C(cdk.App, (define) => {
  define`my-stack`(Stack);
});

new App().synth();
import * as cdk from "@aws-cdk/core";
import * as lambda from "@aws-cdk/aws-lambda";
import path from "path";

const code = new lambda.AssetCode(path.resolve(__dirname, "lambda"));

class Stack extends cdk.Stack {
  fn;

  constructor(scope: cdk.App, id: string) {
    super(scope, id);

    this.fn = new lambda.Function(this, "my-fn", {
      code,
      handler: "index.handler",
      runtime: lambda.Runtime.NODEJS_12_X,
    });
  }
}

class App extends cdk.App {
  constructor() {
    super();

    new Stack(this, "my-stack");
  }
}

new App().synth();

SQS + SNS

import {C} from "concise-constructs";
import * as cdk from "@aws-cdk/core";
import * as sqs from "@aws-cdk/aws-sqs";
import * as sns from "@aws-cdk/aws-sns";

const Stack = C(cdk.Stack, (define) => {
  const queue = define`HelloCdkQueue`(sqs.Queue, {
    visibilityTimeout: cdk.Duration.seconds(300),
  });

  const topic = define`HelloCdkTopic`(sns.Topic);

  topic.addSubscription(new subs.SqsSubscription(queue));

  return {queue, topic};
});

const App = C(cdk.App, (define) => {
  const stack = define`my-stack`(Stack);
  stack.queue; // sqs.Queue
  stack.topic; // sns.Topic
});
import * as cdk from "@aws-cdk/core";
import * as sqs from "@aws-cdk/aws-sqs";
import * as sns from "@aws-cdk/aws-sns";

class HelloCdkStack extends cdk.Stack {
  queue;
  topic;

  constructor(scope: cdk.App, id: string) {
    super(scope, id, props);

    this.queue = new sqs.Queue(this, "HelloCdkQueue", {
      visibilityTimeout: cdk.Duration.seconds(300),
    });

    this.topic = new sns.Topic(this, "HelloCdkTopic");

    topic.addSubscription(new subs.SqsSubscription(this.queue));
  }
}

class App extends cdk.App {
  constructor() {
    super();

    const stack = new Stack(this, "my-stack");
    stack.queue; // sqs.Queue
    stack.topic; // sns.Topic
  }
}

new App().synth();

Lambda CRON

import {C} from "concise-constructs";
import * as cdk from "@aws-cdk/core";
import * as events from "@aws-cdk/aws-events";
import * as lambda from "@aws-cdk/aws-lambda";
import * as targets from "@aws-cdk/aws-event-targets";

const code = new lambda.AssetCode(path.resolve(__dirname, "lambda"));

const Stack = C(cdk.Stack, (define) => {
  const lambdaFn = define`singleton`(lambda.Function, {
    code,
    handler: "index.handler",
    timeout: cdk.Duration.seconds(300),
    runtime: lambda.Runtime.PYTHON_3_6,
  });

  const rule = def`rule`(events.Rule, {
    schedule: events.Schedule.expression("cron(0 18 ? * MON-FRI *)"),
  });

  rule.addTarget(new targets.LambdaFunction(lambdaFn));
});

const App = C(cdk.App, (define) => {
  const stack = define`my-stack`(Stack);
});

new App().synth();
import * as cdk from "@aws-cdk/core";
import * as events from "@aws-cdk/aws-events";
import * as lambda from "@aws-cdk/aws-lambda";
import * as targets from "@aws-cdk/aws-event-targets";

const code = new lambda.AssetCode(path.resolve(__dirname, "lambda"));

class Stack extends cdk.Stack {
  constructor(scope: cdk.App, id: string) {
    super(scope, id);

    const lambdaFn = new lambda.Function(this, "singleton", {
      code,
      handler: "index.handler",
      timeout: cdk.Duration.seconds(300),
      runtime: lambda.Runtime.PYTHON_3_6,
    });

    const rule = new events.Rule(this, "rule", {
      schedule: events.Schedule.expression("cron(0 18 ? * MON-FRI *)"),
    });

    rule.addTarget(new targets.LambdaFunction(lambdaFn));
  }
}

class App extends cdk.App {
  constructor() {
    new Stack(this, "my-stack");
  }
}

new App().synth();

Contributing

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.