https://github.com/willworks/leibniz
A Node.js framework build with Koa2
https://github.com/willworks/leibniz
Last synced: 9 months ago
JSON representation
A Node.js framework build with Koa2
- Host: GitHub
- URL: https://github.com/willworks/leibniz
- Owner: willworks
- License: mit
- Created: 2017-04-24T09:05:52.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-24T05:47:46.000Z (about 9 years ago)
- Last Synced: 2025-07-27T08:51:48.542Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 188 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# A Node.js framework build with Koa2
[](https://circleci.com/gh/ruiming/leibniz)
[](https://codecov.io/gh/ruiming/leibniz)
[](https://img.shields.io/node/v/leibniz.svg)
[](https://img.shields.io/david/ruiming/leibniz.svg?maxAge=2592000)
[](https://img.shields.io/david/dev/ruiming/leibniz.svg?maxAge=2592000)
[](https://img.shields.io/github/release/ruiming/leibniz.svg?maxAge=2592000)
[](https://img.shields.io/npm/l/leibniz.svg?maxAge=2592000)
Build for RESTful Web services
## TodoList
- [ ] ratelimit 中间件自动装载
- [ ] 配置文件及读取,据此配置中间件加载等
- [ ] context 扩展方法
- [ ] request 扩展方法
- [ ] util 工具类
- [ ] 使用 use 来加载模块,模拟命名空间
## Example
- app.js
```javascript
import Leibniz from 'leibniz'
const app = new Leibniz()
app.listen(8000)
```
- controller/post.js
```javascript
import { Get, Controller, Validate, Joi } from 'Leibniz'
@Controller('/post')
export default class PostController {
@Get('/:id')
@Validate({
params: {
id: Joi.number().integer()
}
})
async index (ctx) {
const data = await ctx.service.post.show(id)
ctx.status = 200
ctx.body = {
success: true
}
}
}
```
- service/post.js
```javascript
export default class PostService {
static async show (id) => {
return await Database.Post.findById(id)
}
}
```
All done.
[](https://github.com/feross/standard)