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.
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/faasand 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.ymland developers had to use multiple decorators such as
@Func. v2.0 adopts the application‑style
@Controllerdecorator for HTTP functions, eliminates the need for the
functionsfield in
f.yml, and automatically registers routes from code. Common parameter decorators like
@Query,
@Body,
SetHeader, and
ContentTypeare also supported.
Framework Integration
The
@midwayjs/faasframework is now a first‑class function framework with the same
Applicationand
Contextdefinitions as regular Midway applications, allowing identical
appmethod usage.
Configuration Improvements
The entry file
configuration.tsnow supports functional style definitions, enabling function‑style coding in integrated scenarios.
Toolchain Upgrade
Midway v2.0 switches to
@midwayjs/clias 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
invokemethod is replaced by a more natural testing approach using
supertestfor HTTP simulations and
runFunctionfor function testing.
Web Mode
Traditional frameworks such as Egg, Koa, and Express can be seamlessly migrated to serverless environments via the
deployTypefield 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
supertestand
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.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.