Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu

1,659次阅读
没有评论

English | 简体中文

Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu

Malagu

Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu
Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu
Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu
Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu
Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu

Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu

Malagu 是基于 TypeScript 的 Serverless First、组件化、平台无关的渐进式应用框架。

特征

  • 约定大于配置,零配置,开箱即用
  • TypeScript 版 Spring Boot
  • Serverless First
  • 平台不锁定
  • 支持前后端一体化,前端框架不锁定
  • 支持微服务
  • 组件化,渐进式
  • 命令行工具插件化
  • 依赖注入
  • 面向切面编程(AOP)
  • 集成了流行的 ORM 框架,使用装饰器声明式事务管理
  • 支持 OIDC 认证
  • 支持 OAuth2 授权
  • 使用 rxjs 管理状态
  • 提供 REST 和 RPC 两种接口风格

Malagu 名字由来:在我的家乡,谐音“吗啦咕”是小石头的意思,小石头堆砌起来可以建成高楼大厦、道路桥梁,而 Malagu 组件编排可以实现千变万化的应用。

快速开始

# 安装命令行工具
npm install -g @malagu/cli

# 初始化
malagu init -o project-name
cd project-name # 进入项目根目录

# 运行
malagu serve

# 部署
malagu deploy -m scf # 部署到腾讯云云函数(SCF)
malagu deploy -m fc # 部署到阿里云函数计算(FC)
malagu deploy -m lambda # 部署到 AWS Lambda

Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu

示例

文档

依赖注入

// 类对象注入
@Component()
export class A {

}

@Component()
export class B {
@Autowired()
protected a: A;
}

// 配置属性注入
@Component()
export class C {
@Value(foo) // 支持 EL 表达式语法,如 @Value(‘obj.xxx’)、@Value(‘arr[1]’) 等等
protected foo: string;
}

数据库操作

import { Controller, Get, Param, Delete, Put, Post, Body } from @malagu/mvc/lib/node;
import { Transactional, OrmContext } from @malagu/typeorm/lib/node;
import { User } from ./entity;
@Controller(users)
export class UserController {

@Get()
@Transactional({ readOnly: true })
list(): Promise<User[]> {
const repo = OrmContext.getRepository(User);
return repo.find();
}
@Get(:id)
@Transactional({ readOnly: true })
get(@Param(id) id: number): Promise<User | undefined> {
const repo = OrmContext.getRepository(User);
return repo.findOne(id);
}
@Delete(:id)
@Transactional()
async remove(@Param(id) id: number): Promise<void> {
const repo = OrmContext.getRepository(User);
await repo.delete(id);
}
@Put()
@Transactional()
async modify(@Body() user: User): Promise<void> {
const repo = OrmContext.getRepository(User);
await repo.update(user.id, user);
}
@Post()
@Transactional()
create(@Body() user: User): Promise<User> {
const repo = OrmContext.getRepository(User);
return repo.save(user);
}
}

交流群

Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu

状态

Gitee 推荐 | TypeScript 编写的渐进式应用框架 Malagu

Read More 

正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 0
评论(没有评论)

文心AIGC

2023 年 3 月
 12345
6789101112
13141516171819
20212223242526
2728293031  
文心AIGC
文心AIGC
人工智能ChatGPT,AIGC指利用人工智能技术来生成内容,其中包括文字、语音、代码、图像、视频、机器人动作等等。被认为是继PGC、UGC之后的新型内容创作方式。AIGC作为元宇宙的新方向,近几年迭代速度呈现指数级爆发,谷歌、Meta、百度等平台型巨头持续布局
文章搜索
热门文章
手把手教你用AI 10分钟生成一个APP!零基础也能搞定

手把手教你用AI 10分钟生成一个APP!零基础也能搞定

今日,我将向大家展示DeepSeek的全新玩法——从零开始,利用AI创建一个完整的应用程序。借助DeepSee...
最新评论
ufabet ufabet มีเกมให้เลือกเล่นมากมาย: เกมเดิมพันหลากหลาย ครบทุกค่ายดัง
tornado crypto mixer tornado crypto mixer Discover the power of privacy with TornadoCash! Learn how this decentralized mixer ensures your transactions remain confidential.
ดูบอลสด ดูบอลสด Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Obrazy Sztuka Nowoczesna Obrazy Sztuka Nowoczesna Thank you for this wonderful contribution to the topic. Your ability to explain complex ideas simply is admirable.
ufabet ufabet Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
ufabet ufabet You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
ufabet ufabet Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
热评文章
手把手教你用AI 10分钟生成一个APP!零基础也能搞定

手把手教你用AI 10分钟生成一个APP!零基础也能搞定

今日,我将向大家展示DeepSeek的全新玩法——从零开始,利用AI创建一个完整的应用程序。借助DeepSee...