This article is shared by Ting Zhang, a member of the Amoy Node architecture team

In every era, there is no shortage of opportunities.

From 2014 to now, the voice of the cloud has not stopped, and now to 2020, cloud manufacturers are ready, and the front, is ready to step into the field of this dispute, to embrace the honey given by the era, or is it a thorny rose?

Everyone is more or less in to receive information on the battlefield of the cloud, now, can’t help to study, comparing the function of each cloud platform, even the actual research, consider using in your product or business, ali and internally after a year of practice and summary the Serverless and organic integration of existing framework together, at the same time, The hope is to simplify cloud function development for existing communities.

This article is to teach you how to avoid stepping on the pit (hand).

PS. The end of the welfare broadcast, 7 days to play cloud development, free development and multiple gifts!

The first trick to avoid a pit

Alibaba’s Midway architecture, a Web stack development framework, was introduced last year. The transition from a traditional Web to a Serverless system is not so easy, and seemingly clean code can even become shackles in a Severless system.

As the saying goes, gather is a ball of fire, scattered is all over the sky stars, take a simple Web request, we think is, I an interface into a function, very simple. My application, depending on the route, might be divided into 1,2,3,4… 100 ports. The reality is that a Web request, the moment it receives the data, the hole is already dug and ready to jump.

The first pit is coming, which platform should I choose? To avoid choosing a platform in advance, Midway FAas uses a fixed template code that requires the installation of our CLI tools.



The MIDWAY FAas CLI “F” was also written in Node.js, and most front-end developers will start using Serverless for the first time soon. At the same time, it also integrates ali Cloud, Tencent cloud and many other cloud vendors cloud service release, and supports the development, debugging, deployment and other capabilities.

We can create our first example function with “f”.

Its CLI is also written in Node.js, so it’s probably where most front-end developers first started with Serverless.

Midway FAAS code files are in class form so that all methods can be a reusable function and still enjoy the power of traditional OO.

Second trick to avoid the pit

The following code propaganda of each cloud platform is deeply popular.

These simple promotional functions, both similar and slightly different (not recommended), basically return Hello World via callback or the standard format (and HTTP Response).

For the front end, front and back end separation, DevOPS, to the full stack development baptism, has been relatively familiar with Koa/Egg and other Web development routine, to Serverless, my code how to do?

Don’t worry, Midway Faas has it all figured out.

You’ll notice that this is exactly the same as the traditional KOA interface, as long as you know koA, you’ll be able to use it in a flash. Use the apis you’re familiar with and get into the development rhythm quickly.

In addition, you can use most of the Midway Web development decorators, or even just copy the business code, and the entire Midway FAAS framework will help you integrate and run.

The third trick to avoid a pit

At this time, our code was finished. According to the traditional development mode of Serverless, we either installed a Docker locally and tested it according to the way of the platform, or directly packaged and released to the platform for testing and debugging.

In our survey, local installation of Docker is too unfriendly to the front end. Whenever we propose to do something through Docker, the trial party will ask whether it can be lighter and whether the Web development can start the service and refresh the browser like the traditional development before.

Our answer to this is yes, with the invoke command, which can either invoke directly or start a service.



The familiar http://127.1:3000 has been launched, developed and debugged as you wish.

The fourth trick to avoid pits

Code development completed, also test completed, we can be released to the platform, at this time, Ali cloud, Tencent cloud, in fact, depends on your preferences.

Which platform do you want to publish to, just configure it.

Then deploy.

We see a lot of advertising, no operation and maintenance, charge on request, low cost, simplify logic, let Serverless into thousands of households. There is a Gap between the essence and traditional application development. Serverless uses YML to configure aggregate resources and provides resource services by the platform. The business only needs to write a single logical code.

While our code can be written without considering multiple interfaces, the original question remains unanswered: “What about publishing and managing multiple interfaces?” .


Midway faas USES a custom interface polymerization mode, according to the flow model, the user can decide to deploy patterns, our f.y ml can undertake free configuration, you can decide to bring together all interfaces, deployed to a function in the container enjoy the overall scalability, can also remove the hot interface arbitrary single deployment, All of this requires no code modification, just the YML configuration file.

Final Guide

We’ve rounded it up and the pothole guide tells you a few things:

  • 1. Avoid platform selection ahead of time and focus on development

  • 2. Avoid new wheels and reuse traditional capabilities

  • 3. Avoid platform testing and debug locally in advance

  • 4. Avoid extra fees and use free plans whenever possible

So, in the end, we avoided all kinds of pitfalls, and did some simple Web interfaces (applications) without spending extra money ($16 for a domain name), and reduced costs (down the road to socialist platform fleas).

Midway FAAS is a framework for the front-end gateway Serverless and the future of capabilities collaboration and production in the cloud. These solutions are just a small part of the midway FAAS framework, which offers more of the traditional dependency injection, decorator customization, business configuration management, and componentization capabilities. There are even custom runtimes and privatized deployments, which will be shown in the future.

We want “Midway will always be with you”.

Warehouse: https://github.com/midwayjs/midway-faas < — chuo chuo Star

Documents: https://www.yuque.com/midwayjs/faas

Ali Cloud Platform has recently taken some examples of Midway FAAs and developed them in the cloud with deep customization. Both the Web stack application and the SSR example can be built with a single click. It is developed in the traditional way, supports scalability, and has flexible functional interfaces. What are you waiting for?

Address: https://workbench.aliyun.com/camp



At the end of the article’s welfare

Play in the cloud7 daysTraining camp


Enjoy the original development environment of the cloud era in advance, Serverless RESEARCH and development from entry to mastery, continuous 7 days, a live broadcast every day, Ali experts hand in hand to teach you to use Ali Cloud development platform get cloud development new skills. 0 threshold to open the browser can be developed, the fastest 1 minute to build a personal website, free development also send vouchers, Tmall genie and other multiple gifts!


Identify the following TWO-DIMENSIONAL code immediately into the group learning