Fetch the repository succeeded.
English | 简体中文
Malagu is a Serverless First, componentized, platform-independent progressive application framework based on TypeScript.
The origin of Malagu's name: In my hometown, the homophonic "Ma Lagu" means small stones. The small stones can be piled up to build high-rise buildings, roads and bridges, and the arrangement of Malagu components can realize ever-changing applications.
# Install command-line tools
npm install -g @malagu/cli
# Initialization
malagu init -o project-name
cd project-name # Enter the project root directory
# Running
malagu serve
# Deployment
malagu deploy -m scf # Deploy to Tencent Cloud Function(SCF)
malagu deploy -m fc # Deploy to Alibaba Cloud Function Compute(FC)
malagu deploy -m lambda # Deploy to AWS Lambda
// Class object injection
@Component()
export class A {
}
@Component()
export class B {
@Autowired()
protected a: A;
}
// Configuration property injection
@Component()
export class C {
@Value('foo') // Support EL expression syntax, such as @Value('obj.xxx'), @Value('arr[1]') etc.
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);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. Open source ecosystem
2. Collaboration, People, Software
3. Evaluation model