我们可以使用 Malagu 框架开发纯后端应用,后端应用可以是微服务、BFF(Backend for Frontend)等等。如何使微服务应用,我们可以使用 @malagu/typeorm 组件来操作数据库;如果是 BFF 应用,我们可以使用 axios 模块(推荐使用框架内置的 RestOperations 服务,可以使用装饰器 @Autowired(RestOperations) 即可),或者使用 SDK 访问微服务。
@Controller()export class UserController {@Autowired(RestOperations)protected restOperations: RestOperations;}
快速开始
Malagu 框架提供了命令行模板,我们可以通过 malagu init 命令快速创建一个后端应用项目。选择如下模板:
➜ test malagu init___/'\_/`\ /\_ \/\ \ __ \//\ \ __ __ __ __\ \ \__\ \ /'__`\ \ \ \ /'__`\ /'_ `\/\ \/\ \\ \ \_/\ \/\ \L\.\_ \_\ \_/\ \L\.\_/\ \L\ \ \ \_\ \\ \_\\ \_\ \__/.\_\/\____\ \__/.\_\ \____ \ \____/\/_/ \/_/\/__/\/_/\/____/\/__/\/_/\/___L\ \/___//\____/@malagu/cli@1.9.0 \_/__/? Select a template to init (Use arrow keys or type to search)❯ backend-app Officialsample-app Officialdatabase-app Officialadmin-app Officialmicroservice Officialpuppeteer Officialmulti-component Officialmycli Officialsite Official

