English | 简体中文
Malagu is a Serverless First, Component-based, platform-independent, progressive application framework based on TypeScript.
- Convention over configuration, zero configuration, out of the box
- Spring Boot for TypeScript
- Serverless First
- The platform is not locked.
- Support for front-end integration, front-end framework is not locked
- Support microservices
- Componentized, Progressive
- Plug-in command line tools
- Dependency injection
- Facet-oriented programming (AOP)
- Integrates with the popular ORM framework for declarative transaction management using decorators.
- Support for OIDC accreditation
- OAuth2 authorization support
- Managing Status with rxjs
- Both REST and RPC interface styles available
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/cli
# Initialization
malagu init project-name
cd project-name # Enter the project root directory
# Running
malagu serve
# Deployment
malagu deploy
- Introduction
- Quick Start
- Command line tools
- Controller
- Database operations
- Microservice
- Authentication and authorization
- Cloud Platform Adaptation
- Dependency injection
- Component design
- Front-end architecture
- React development
- Front and back-end integrated development
// 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);
}
}