tiantong-test
v0.0.7
Published
基于bun的类springboot框架
Downloads
8
Readme
Quick Start
基于Bun的类springboot框架
已实现功能
- [x] Module
- [x] Controller
- [x] Service
- [x] Injectable
- [x] Provider
已实现功能路由修饰器
- [x] @Post
- [x] @Get
已实现功能参数修饰器
- [x] @Query
- [x] @Param
- [x] @Body
In Node.js
npm install -g bun
npm install tiantong --save
import { Factory } from 'tiantong'
import { AppModule } from './app.module'
Factory.create({ module: AppModule })
Factory.listen(3000)
Module
import { UserController } from '@/modules/user/user.controller.ts'
import { UserService } from '@/modules/user/user.service.ts'
import { Module } from 'tiantong'
@Module({
controllers: [UserController],
providers: [UserService],
})
export class UserModule {}
Controller
import { UserService } from '@/modules/user/user.service.ts'
import { Body, Controller, Get, Param, Post } from 'tiantong'
@Controller('user')
export class UserController {
test: string
constructor(private userService: UserService) {
this.test = 'test1111'
}
@Get('')
getUser(@Param('id') id: number) {
return {
id,
}
}
@Post('add')
addUser(@Body() body: any, @Body('id') id: number) {
return {
id,
body,
this: this,
str: 'add user',
userService: this.userService.getUser(),
}
}
@get('delete/:id')
addUser(@Param('id') id: string) {
return {
id,
}
}
}
Server
import { Injectable } from 'tiantong'
@Injectable()
export class UserService {
getUser() {
return 'test'
}
}