Add an example for cloud.HttpServer
This example is similar to `cloud-js-api` but uses cloud.HttpServer instead of cloud.API.  For now, we will include both examples to show both styles.
ADD
cloud-js-httpserver/.gitignore
+/node_modules/

ADD
cloud-js-httpserver/Pulumi.yaml
+name: cloud-js-httpserver
+description: A simple HTTP server that returns the number of times a route has been hit.
+runtime: nodejs

ADD
cloud-js-httpserver/index.js
+const cloud = require("@pulumi/cloud");
+const express = require("express");
+
+// Create a mapping from 'route' to a count
+let counterTable = new cloud.Table("counterTable", "route");
+
+// Create an HTTP server using Express
+let routeCountServer = new cloud.HttpServer("routecount", () => {
+ let app = express();
+
+ // Handle any route, incrementing count of times that route has been requested
+ app.get("*", (req, res) => {
+ let route = req.path;
+ console.log(`Getting count for '${route}'`);
+
+ // Increment count in the counter Table created above
+ counterTable.get({ route }).then(value => {
+ let count = (value && value.count) || 0;
+ return counterTable.insert({ route, count: ++count }).then(() => {
+ res.status(200).json({ route, count });
+ console.log(`Got count ${count} for '${route}'`);
+ });
+ }).catch(err => {
+ res.status(500).send(err.toString());
+ console.error(`Failed to get count for '${route}': ${err.toString()}`);
+ });
+ });
+
+ return app;
+});
+
+exports.endpoint = routeCountServer.url;

ADD
cloud-js-httpserver/package.json
+{
+ "name": "cloud-js-httpendpoint",
+ "main": "index.js",
+ "dependencies": {
+ "@pulumi/cloud": "^0.15.1",
+ "@pulumi/cloud-aws": "^0.15.1",
+ "express": "^4.16.3"
+ }
+}

Add an example for cloud.HttpServer (#147)

This example is similar to `cloud-js-api` but uses cloud.HttpServer instead of cloud.API.  For now, we will include both examples to show both styles.