cellbang / cell

Cell is a Serverless First, componentized, platform-independent progressive application framework based on TypeScript. Cell 是基于 TypeScript 的 Serverless First、组件化、平台无关的渐进式应用框架。
https://malagu.naily.cc
MIT License
701 stars 62 forks source link
aliyun aws bff dependency-injection faas microapp microservice orm platform-independent serverless serverless-framework tencent-cloud typescript vecel

English | 简体中文

Cell Logo

Cell

GitHub license npm version npm downloads Build Status star

Cell is a Serverless First, componentized, platform-independent progressive application framework based on TypeScript.

Features

Quick start

# Install command-line tools
npm install -g @celljs/cli

# Initialization
cell init -o project-name
cd project-name # Enter the project root directory

# Running
cell serve

# Deployment
cell deploy -m scf      # Deploy to Tencent Cloud Function(SCF)
cell deploy -m fc       # Deploy to Alibaba Cloud Function Compute(FC)
cell deploy -m lambda   # Deploy to AWS Lambda

Quick Start

Samples

Documentation

Dependency injection

// 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;
}

Database operations

import { Controller, Get, Param, Delete, Put, Post, Body } from '@celljs/mvc/lib/node';
import { Transactional, OrmContext } from '@celljs/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);
    }
}

Discuss group

群二维码.png

Status

Alt