Malagu is a Serverless First, component-based, platform-independent, progressive application framework based on TypeScript.
English | 简体中文
Malagu is a Serverless First, Component-based, platform-independent, progressive application framework based on TypeScript.
The Malagu name comes from the fact that where I come from, the word "malagu" means small stone, and while small stones can be built into tall buildings, roads, and bridges, the Malagu Component layout can be used in a myriad of ways.
# Install command-line tools npm install -g yarn npm install -g @malagu/cliInitialization
malagu init project-name cd project-name # Enter the project root directory
Running
malagu serve
Deployment
malagu deploy
// 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); }
}