Midway Serverless 2.0: What’s New and Why It Boosts Your Backend Productivity

Midway Serverless 2.0 (codenamed “Hercules”) revamps the original framework with unified decorators, a modern CLI, faster Vite‑based builds, enhanced testing, and seamless integration of traditional web frameworks, delivering a smoother, more efficient serverless development experience.

Taobao Frontend Technology
Taobao Frontend Technology
Taobao Frontend Technology
Midway Serverless 2.0: What’s New and Why It Boosts Your Backend Productivity

Midway Serverless Evolution

Since the release of Midway Serverless 1.0, many teams have leveraged its elastic containers to offload infrastructure and operations, allowing frontend developers to write a few functions that implement backend logic and accelerate product launches. In March 2021 Midway Serverless 2.0 (code‑named “Hercules”) was launched to address the shortcomings of v1.0 and further improve developer experience and efficiency.

What Midway Serverless Is

Midway Serverless is a development solution for serverless cloud platforms. It mainly consists of the function framework @midwayjs/faas and a suite of supporting tools and starters.

Major Changes in v2.0

Pure Function Enhancements

HTTP‑related functions (HTTP triggers, API gateways, etc.) receive additional support, especially for the HTTP scenario.

Decorator Unification

In v1.0 trigger parameters were defined in f.yml and developers had to use multiple decorators such as @Func. v2.0 adopts the application‑style @Controller decorator for HTTP functions, eliminates the need for the functions field in f.yml, and automatically registers routes from code. Common parameter decorators like @Query, @Body, SetHeader, and ContentType are also supported.

Framework Integration

The @midwayjs/faas framework is now a first‑class function framework with the same Application and Context definitions as regular Midway applications, allowing identical app method usage.

Configuration Improvements

The entry file configuration.ts now supports functional style definitions, enabling function‑style coding in integrated scenarios.

Toolchain Upgrade

Midway v2.0 switches to @midwayjs/cli as the base CLI, gradually deprecating @midwayjs/faas-cli. The new CLI offers on‑demand plugin loading, reducing installation size and improving speed.

Unit Test Upgrade

The old invoke method is replaced by a more natural testing approach using supertest for HTTP simulations and runFunction for function testing.

Web Mode

Traditional frameworks such as Egg, Koa, and Express can be seamlessly migrated to serverless environments via the deployType field in f.yml. Code can also be deployed to conventional containers or Docker using @midwayjs/serverless-app, preserving the same coding model.

Integrated Capability Enhancements

The one‑stop coding solution is further refined:

Fast startup with Vite reduces build time from ~20 seconds to under 2 seconds.

Integrated testing now supports both supertest and runFunction.

The solution can be used for both function and application development, extending Midway projects to the integrated mode.

Runtime upgrades replace the previous compiler‑based entry with native frameworks and Node modules, removing previous limitations and allowing custom hooks.

Future Outlook

Midway Serverless 2.0 brings many upgrades, yet the roadmap continues to add new capabilities so that developers can fully enjoy the benefits of the serverless and cloud era.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLICloud NativeServerlessbackend-developmentMidway
Taobao Frontend Technology
Written by

Taobao Frontend Technology

The frontend landscape is constantly evolving, with rapid innovations across familiar languages. Like us, your understanding of the frontend is continually refreshed. Join us on Taobao, a vibrant, all‑encompassing platform, to uncover limitless potential.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.