v1.0
is in alpha state, feel free to give it a try: branch v1.0
$ npm install koa@next @types/koa @t2ee/vader --save
This is the core component of t2ee, the routing service.
Bring your own 'reflect-metadata'
import 'reflect-metadata';
@Path('/')
class TestController {
@GET
@Produce(MediaType.JSON)
@Path('/')
async index() {
return new Response()
.status(200)
.entity({
message: 'hello world',
})
.build();
}
}
const app = new Koa();
const router = new Router();
router.use(TestController);
app.use(router.routes());
app.listen(8080);
##API
provide custom annotations that can be managed by vader.
register a controller to router
return a middleware function to be used in Koa.
set content
set status
set header
build response before return
- headers
- params
- query
- body
- http: Koa.Context
- [key: string]: any // used to store any intermediate state.
used to get body of item of specified key
used to get header of item of specified key
used to get path variables of item of specified key
used to get query of item of specified key
set reqeust body content type
set response body content type
set reqeust method
get current VaderContext
plug in custom middleware
charset enums
http method enums
content type enums
http status enums
PRs and Issues are welcome