9 Star 162 Fork 14

GVPcellbang / malagu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

English | 简体中文

Malagu Logo

Malagu

GitHub license npm version npm downloads Build Status star

Cloud Studio Template

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

Quick Start

示例

文档

依赖注入

// 类对象注入
@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);
    }
}

交流群

群二维码.png

状态

Alt

MIT License Copyright (c) 2019 Cellbang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Malagu 是基于 TypeScript 的 Serverless First、组件化、平台无关的渐进式应用框架。 展开 收起
TypeScript 等 5 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/cellbang/malagu.git
git@gitee.com:cellbang/malagu.git
cellbang
malagu
malagu
master

搜索帮助