Malagu Save Abandoned

Malagu Development Framework 最新项目地址为:https://github.com/cellbang/malagu

Project README

Malagu (https://github.com/cellbang/malagu)

Malagu is a serverless First, scalable and componentized application framework developed by TypeScript.

Read this in other languages: 简体中文

Features

  1. Based on TypeScript
  2. Zero configuration
  3. Spring Boot-like development experience
  4. Serverless First
  5. componentization
  6. Front-end and back-end integration
  7. Aspect-oriented programming (AOP)
  8. Integrated ORM framework
  9. The command tool is extensible

The origin of the name Malagu: In my hometown, the homonym "Malagu" means small stones. Stacked small stones can be used to build high-rise buildings, roads and bridges, and Malagu component arrangement can realize a variety of applications.

Document

To check out the document.

Quick Start

  1. Create an application

  1. Run locally

  1. Debug locally

  1. Deploy the application

Dependency injection

@Component()
export class A {

}

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

Property injection

@Component()
export class A {
    @Value('foo') // Support EL expression syntax, such as @Value ('obj.xxx'), @Value ('arr [1]'), etc.
    protected foo: string;
}

MVC

@Controller('users')
export class UserController {
    
    @Get()
    list(): Promise<User[]> {
        ...
    }

    @Get(':id')
    get(@Param('id') id: number): Promise<User | undefined> {
        ...
    }

    @Delete(':id')
    async remove(@Param('id') id: number): Promise<void> {
        ...
    }

    @Put()
    async modify(@Body() user: User): Promise<void> {
        ...
    }

    @Post()
    create(@Body() user: User): Promise<User> {
        ...
    }

}

Database operations

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);
    }
}
Open Source Agenda is not affiliated with "Malagu" Project. README Source: alibaba/malagu
Stars
222
Open Issues
18
Last Commit
2 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating