mimik Serverless Concepts

Traditional microservice development requires developer to consider many concerns related to HTTP server, such as how to deploy a server, which port to use, etc. In order to simplify the process, mimik provides a serverless environment for edgeSDK based microservice development. The edgeSDK takes care of web server deployment and all concerns related to the servers. Developers only need to design the logics of processing HTTP requests and responses. That is why in the IT community, we call this serverless programming.

Programming Model

To start, you supply a callback functions, and you give it to mimikModule.exports. The callback function must have the following parameters.

                  mimikModule.exports = function(context, request, response) {
                    response.statusCode = 200;
                    response.end('<h1>Hello World</h1>');

This gives you full control on HTTP request and response. This is a context to mimik serverless programming environment. Please refer to the API reference for more information.

Other Programming Model

Because the JavaScript interpreter used by mimik serverless container is Duktape, which is a compiler built for embedded devices and lacks features that you would normally find it in a NodeJS environment. One example is the module system.

One way to overcome this, mimik suggest developer to utilize webpack, and configure it to to use Babel.

In short, webpack provides a module system that you would see in a NodeJS, so that you can use npm and require the library. Babel is a transpiler, which allows you to write in newer JavaScript language, such as ES6, and then compile it back to the most basic JavaScript language. For more information, please refer to our example apps, or refer to webpack and Babel website.

We also recommend that one makes the use of npm module router so that the programming model becomes like Express. You can view a demonstration of this way of programming in the example edge microservice on our GitHub.