你可以自由选择后端 api 服务的架构,以及前端开发框架,完全不会影响整体效果。值得一提的是,这里使用的 api 框架是 Serverless Devs 提供的 Serverless first 的开发框架,针对冷启动做了一些优化,你可以采用熟悉框架的开发语法糖,比如这里是采用 koa 式的语法糖,你也可以选择 express 的,具体细节可以访问官方库去查看,非常适合中小型 Web 项目开发。
2、网关说明
其实这个 Web 应用架构核心的部分是在网关,通过网关实现了动静态分流。域名及证书绑定,也是通过网关做各种限流和安全验证。为了更好的使用网关我们开发了 apigateway 的组件,它是基于官方的 sdk 量身定制的 api 发布服务。它是完全开源开放的,你可以根据需要自己去定制更多的网关路由部署流程,比如加入多环境的设置等,这里我对配置做了一些简化,让开发者关注于路由和目标服务,相比自己一个一个去配置 api 要节省很多时间。
文章标题提到了"现代化应用"的概念,在这里也跟大家解释一下,什么是 "Modern Application"。其实现代化应用这个概念已经被越来越被广泛的认可了。不管是阿里云,华为云,AWS 都在推广现代化应用的理念。这里引用一段 AWS 对 Modern Application 的概念解释:
A modern application is the combination of modern technologies, architectures, software delivery practices, and operational processes that lead teams to deliver value more quickly, frequently, consistently, and safely. These applications typically take advantage of loosely coupled, distributed technologies and focus on event-driven, serverless components that allow teams to offload undifferentiated heavy lifting in order to spend more time on delivering value for their customers. A modern application also takes advantage of operational and security tooling to increase the reliability and consistency of deployments, while making it safe to deploy many times a day. The use of automation of infrastructure, security, and deployments allows the teams that own modern applications to move more quickly than if they were relying on manual processes or more significant operational management.