Add simple HTTP endpoint sample
ADD
cloud-js-httpendpoint/.gitignore
+/node_modules/
+/.pulumi/

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

ADD
cloud-js-httpendpoint/index.js
+const cloud = require("@pulumi/cloud-aws");
+
+// Create a mapping from 'route' to a count
+let counterTable = new cloud.Table("counterTable", "route");
+
+// Create an API endpoint
+let endpoint = new cloud.HttpEndpoint("hello-world");
+
+endpoint.get("/{route+}", async (req, res) => {
+ let route = req.params["route"];
+ console.log(`Getting count for '${route}'`);
+
+ // get previous value and increment
+ let value = await counterTable.get({route}); // reference outer `counterTable` object
+ let count = (value && value.count) || 0;
+ await counterTable.insert( { route, count: ++count });
+
+ res.status(200).json({ route, count});
+ console.log(`Got count ${count} for '${route}'`);
+});
+
+module.exports.endpoint = endpoint.publish().url;

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

ADD
cloud-js-httpendpoint/tsconfig.json
+{
+ "compilerOptions": {
+ "outDir": "bin",
+ "target": "es6",
+ "lib": [
+ "es6"
+ ],
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "declaration": true,
+ "sourceMap": true,
+ "stripInternal": true,
+ "experimentalDecorators": true,
+ "pretty": true,
+ "noFallthroughCasesInSwitch": true,
+ "noImplicitAny": true,
+ "noImplicitReturns": true,
+ "forceConsistentCasingInFileNames": true,
+ "strictNullChecks": true
+ },
+ "files": [
+ "index.ts"
+ ]
+}
\ No newline at end of file

Add simple HTTP endpoint sample (#50)