像这样.
import { RouteGroup, get } from 'vio';
// extends `RouteGroup` class.
export default class Default extends RouteGroup {
// route as a HTTP GET request.
@get()
static default() {
// can also be a promise if it's async.
return {
title: 'Hello, VIO!',
content: 'Keep calm and read the source code.'
};
}
}
特性
- 按照文件路径映射路由.
- 开发模式下动态加载路由.
- 返回一个值为相关数据的 promise 即可渲染页面.
- 使用 ES7 装饰器.
当然, 也可以做 JSON API 使用.
Feel terrible inside some logic? Throw an error!