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

umble

v4.0.1

Published

Humble Pulumi Constructs for Apollo/React Developers

Downloads

94

Readme

Umble

Humble Pulumi Constructs for Apollo/React Developers

To use Umble you'll need to install pulumi and umble's subpackages.

For your infrastructure: npx install-peerdeps umble

For your apollo server: npm i umble-apollo-server

Constructs

Service

Here is a quick example on how to use it. The ./app directory requires a Dockerfile that exposes the service on port 4000, pulumi will use docker to build your image.

const pulumi = require('@pulumi/pulumi');
const aws = require('@pulumi/aws');
const awsx = require('@pulumi/awsx');
const { Service } = require('umble');

const repo = new awsx.ecr.Repository('repo', {
  forceDelete: true,
});

const image = new awsx.ecr.Image('image', {
  repositoryUrl: repo.url,
  path: './app',
});

const api = new Service('api', {
  image,
  environment: {
    NODE_ENV: 'production',
  },
});

exports.url = pulumi.interpolate`http://${api.httpListener.endpoint.hostname}`;

The values expressed are defaults. The only required variable is image.

StaticWebApp

Here is a quick example on how to use it with create react app. It can be used with any static site or static site generator.

const pulumi = require('@pulumi/pulumi');
const { StaticWebApp } = require('umble');

const webapp = new StaticWebApp('webapp', {
  buildDir: './webapp/build/',
  buildCmd: 'cd ./webapp && yarn build',
  environment: {
    REACT_APP_ENVIRONMENT: 'PRODUCTION',
  },
});

exports.url = pulumi.interpolate`http://${webapp.bucket.websiteEndpoint}`;

Lambda

Here is a quick example on how to use it with umble-apollo-server. It uses an opinionated abstraction of aws-lambda-graphql which internally extends apollo-server-lambda

const { Lambda } = require('umble-apollo-server');

const apollo = new Lambda('umble', {
  source: './app',
  handler: 'App.http',
  websockets: {
    enabled: true,
    wsHandler: 'App.ws',
    eventHandler: 'App.event',
  },
});

exports.url = apollo.api.url;
exports.websocketUrl = apollo.websocketApi.url;

Your ./app directory should use umble-apollo-server and expose the http, ws, and event handlers.

Servers

ApolloServer

Here is a quick example of what the ./app directory would look like for a basic app.

const { ApolloServer, PubSub } = require('umble-apollo-server');
const { gql } = require('apollo-server');

const pubSub = new PubSub();

const typeDefs = gql`
  type Mutation {
    broadcastMessage(message: String!): String!
  }

  type Query {
    dummy: String!
  }

  type Subscription {
    messageBroadcast: String!
  }
`;

const resolvers = {
  Mutation: {
    broadcastMessage: async (root, { message }) => {
      await pubSub.publish('NEW_MESSAGE', { message });

      return message;
    },
  },
  Query: {
    dummy: () => 'dummy',
  },
  Subscription: {
    messageBroadcast: {
      resolve: (rootValue) => rootValue.message,
      subscribe: pubSub.subscribe('NEW_MESSAGE'),
    },
  },
};

const server = new ApolloServer({
  typeDefs,
  resolvers,
  playground: true,  // playground subscriptions do not work live because it injects headers that AWS is currently unable to resolve
  introspection: true,
});

exports.ws = server.handlers.ws();
exports.http = server.handlers.http();
exports.event = server.handlers.event();