Getting Up & Running with Express Serverless Platform
Express Serverless Platform combines serverless functions, tools for integrations and a microservices API gateway all with automated deployment to your cloud – any cloud. Let’s get started!
Express Serverless Platform combines serverless functions, tools for integrations and a microservices API gateway all with automated deployment to your cloud – any cloud. Let’s get started!
For this helpful, easy-to-follow guide, you will need a Express Serverless Platform 14 day free trial account.
Once you register for an account and activate your email, you will be directed to the Express Serverless Platform Canvas.
The Express Serverless Platform Canvas has a built in walkthrough with easy-to-use prompts that take you through the following steps: how to create a microservice, deploy and configure an API Gateway, connect a microservice to the API Gateway, and expose it as an API Endpoints. Then, you’ll trace your API workflow from public API Endpoints to your in-memory data source. If you have any questions or get stuck, hit us up on our chat at the bottom right hand corner or [email protected].
After you log in to the Express Serverless PlatformCanvas, you can build a microservices application in two minutes by following the built-in walkthrough.
When you log in you will be directed to the Express Serverless Platform Canvas. Think of the Canvas as a “single pane of glass” that visualizes all of the moving parts in your microservices application.
The Canvas is broken up into a few easy parts: Entity Palette, Quadrants and Panels.
Navigate to the Entity Palette to access a collection of Connectors.
Access a collection of Connectors in the Entity Palette through the Connectors Submenu.
Choose the Memory Connector from the Data Source Entities Menu to add it to your project on the LunchBadger Canvas.
Connectors are pre-built libraries for Model functions that allow you to utilize popular data sources and services. Each Data Source comes with it’s own set of properties.
Unlike other connectors, the Memory Connector acts as its own in-memory database and is perfect for getting our project started quickly.
For most Connectors connecting a data source, you would specify the data source properties such as host or port.
Because the Memory Connector acts as its own in-memory database, you do not need to specify those properties at this time.
Navigate to Model Entity on the Entity Palette.
Add a Model Entity.
There are a few important things you should know about a Model. All Models are Node.js JavaScript functions. Models have the following basic built in functionality to save you time:
Let’s define the context path as cars.
You’ve create the Model and defined the context path.
Now, click the plus icon to add properties you would like to expose from your data to your API Endpoint.
Wiring up Entities in LunchBadger is as easy as dragging a connection from one entity to another.
Activate the connection by clicking on the port.
Drag and drop the connection to the from your Memory Connector port to the port on your Car Model.
The Car Model can now store its data in the in-memory database through the Memory Connector.
Deploy a Serverles Function called “MyFunction” in just a few easy steps.
This Function comes with default function code to return the string “LunchBadger Function” when it’s run in your Kubernetes cluster.
Functions are “serverless” pieces of code that can be written in any number of languages including:
Functions are similar to Models. Both entities are programming functions, but Functions are completely barebone and do not have any built in functionality.
Navigate to Function Entity in the Entity Palette.
Choose Node 8 and Click OK to deploy the Function
Now that the Function is deployed, you can explore more details about the Function by clicking on the details icon to access Express Serverless Platform’s built-in code editor.
Express Serverless Platform Canvas uses an API Gateway to expose your microservices (models, functions, service endpoints etc) as HTTP based APIs. Gateways secure and manage the APIs through a set of policies like authorization, authentication, rate limiting and other quality of service functionality.
We use Express Gateway, an open source API Gateway, as our API Gateway in the Express Serverless Platform.
Navigate to Gateway Entity in the Entity Palette.
Add the Gateway to your project by clicking on the Gateway icon. We’ll customize it in the next step.
The Gateway is made of Pipelines, a collection of policies that are invoked when an API Endpoint is called.
You can use Pipelines to connect a microservice to a corresponding API Endpoint. Data will flow through a Pipeline in the Gateway to ensure Policies (i.e., authentication/authorization) are enforced.
The “CarPipeline” will already contain a Proxy policy.
You can configure a unique set of policies to handle different sets of API Endpoints for each Pipeline. For more complex applications you can add as many Pipelines as needed to be able to handle each set of API Endpoints.
The “FunctionPipeline” will also contain its own Proxy policy.
Wiring up microservices to the Gateway is as simple as drawing a connection from the microservice entity’s right port to the Pipeline’s left port.
Activate the connection by clicking on the port.
Drag and drop the connection to the from your Car Model port to the CarPipeline port in the Gateway.
The Car Model can now connect to API Endpoints through CarPipeline and Policies in the Gateway.
A corresponding API Endpoint is automatically generated when you connect a microservice entity to the Gateway’s Pipeline for the first time.
Rename the exposed API Endpoint to CarAPIEndpoint.
CarAPIEndpoint will have a path specified for invocation – “/cars*” taken from the context path Car Model
Connect the Function to the Gateway via the FunctionPipeline to expose the Function as an API Endpoint.
Activate the connection by clicking on the port.
Drag and drop the connection to the from MyFunction port to the FunctionPipeline port in the Gateway.
The Function can now connect to API Endpoints through FunctionPipeline and Policies in the Gateway.
Just like when we created the CarPipeline, a corresponding API Endpoint is automatically generated and pre-connected to the FunctionPipeline.
The Path as is automatically set to /myfunction* from the function name
Click OK to create the MyFunction API endpoint
Let’s Try It!
With a few clicks, you’ve created two sets of microservices, Car Model and MyFunction.
The Car Model, is a Model with built-in CRUD functionality (through Connectors) and a rich REST API automatically generated for you.
MyFunction, is a serverless Function that you can write in a number of languages and invoke through the API Gateway.
Both microservices are exposed and ready to be invoked with their own API Endpoints .
curl https://<root url>/api/cars
and
curl https://<root url>/api/myfunction
Learn how Express Serverless Platform can help you quickly deliver on an API strategy that is secure, scalable, for both developers and operations teams.