We’re giving away 1,500 DJI Tello drones. Enter to win ›
Get the code
View the demo
By Daniel Krook | Published July 18, 2017 - Updated July 18, 2017
Serverless platforms, like IBM Cloud Functions powered by Apache OpenWhisk, provide a runtime that scales up or down automatically in response to demand. This results in overall lower cloud resource consumption and a better match between business value gained and the cost of the resources that are used. This code pattern shows you how you can use Cloud Functions to map HTTP REST API calls to business logic functions that create, read, update, and delete entities, and how each API method handler action scales (and is billed) independently in direct correlation to the volume of requests.
This project shows how serverless, event-driven architectures execute code in response to demand from HTTP REST API calls. No resources are consumed until the API endpoints are invoked. When they are called, resources are provisioned to exactly match the current load.
It shows four IBM Cloud Functions (based on Apache OpenWhisk) that write and read data in a MySQL database, demonstrating how actions can work with supporting data services and execute logic in response to HTTP requests.
One function, or action, is mapped to HTTP POST requests. It inserts the supplied cat name and color parameters into the database. A second action is mapped to PUT requests to update those fields for an existing cat. A third action is mapped to GET requests that return specific cat data. A fourth action deletes a given cat data.
The Node.js runtime on IBM Cloud provides built-in whitelist of NPM modules. This demo also highlights how additional Node.js dependencies such as the MySQL client can be packaged in a ZIP file with custom actions to provide high extensibility.
Ready to put this code pattern to use? Complete details on how to get started running and using this application are in the README.
December 11, 2018
December 4, 2018
October 2, 2018
Back to top