Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A framework based on Koa v2.
基于Koa v2的开发框架。
关于发音
英语:Circe[ˈsə:si]
中文:瑟茜[sè xī]
npm install circe --save
// Koa
const Koa = require('koa')
const app = new Koa()
app.use(/* 中间件 */)
app.listen(8080. function () {/* 回调 */})
// Circe
const Circe = require('circe')
const circe = new Circe()
circe.use(/* 中间件 */)
circe.listen(8080. function () {/* 回调 */})
Koa实例对象的属性都有(具体的作用请查看Koa官方文档):
const Circe = require('circe')
const circe = new Circe()
// koa实例
console.log(circe.app)
// server实例,可用于其他框架的结合,如socket.io
console.log(circe.server)
circe.route(Router) 注册路由,传入路由对象
const Circe = require('circe')
const router = new Circe.Router()
router.get('/user', async () => { /* 中间件 */ })
router.post('/user', async () => { /* 中间件 */ })
circe.route(router)
circe.route(Router) 注册路由,传入路由目录
//////// apis/user.js ////////////////////
const Circe = require('circe')
const router = new Circe.Router()
router.get('/user', async () => { /* 中间件 */ })
router.post('/user', async () => { /* 中间件 */ })
module.exports = router
//////// app.js ////////////////////
const Circe = require('circe')
// 将导入apis目录下的所有路由文件
circe.route('./apis')
circe.inject(key, value) 注入内容到context,传入键和值参数
const Circe = require('circe')
const circe = new Circe()
circe.inject('$hello', function () { console.log('hello') })
circe.inject('$a.b', 'test' })
circe.use(asynct (ctx, next) => {
ctx.$hello() // 打印'hello'
ctx.$a.b // 'test'
})
circe.inject(key, value) 注入内容到context,传入对象和前缀
const Circe = require('circe')
const circe = new Circe()
circe.inject({a: 1, b: 2})
circe.inject({c: 3, d: 4}, '$')
circe.inject({e: 5, f: 6}, 'test.')
circe.inject({g: 7, h: 8}, 'test.$')
circe.use(asynct (ctx, next) => {
ctx.a // 1
ctx.b // 2
ctx.$c // 3
ctx.$d // 4
ctx.test.e // 5
ctx.test.f // 6
ctx.test.$g // 7
ctx.test.$h // 8
})
内置的中间件全都绑定在Circe
类上,更多的中间件正在丰富中,致力于实现项目的单一依赖,不需要再去npm或github上需找和对比需要的中间件。
koa-router@7
concurrency-logger
除了koa自带的context方法和属性,circe对context进行了拓展:
FAQs
A framework based on Koa v2.
The npm package circe receives a total of 4 weekly downloads. As such, circe popularity was classified as not popular.
We found that circe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.