在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:venables/koa-plus开源软件地址:https://github.com/venables/koa-plus开源编程语言:JavaScript 100.0%开源软件介绍:koa-pluskoa-plus is the koa framework (v2) extended for APIs. Optimized for security, scalability, and productivity. Features
Each feature can be disabled individually. InstallationInstall
UsageExisting apps:Simply replace your existing Old: const Koa = require('koa')
const app = new Koa()
// ... New: const Koa = require('koa-plus')
const app = new Koa()
// ... ConfigurationSome of the middleware included in Options
Exampleconst Koa = require('koa-plus')
const app = new Koa({
body: {
jsonLimit: '10kb' // Sets the json request body limit to 10k
},
compress: {
threshold: 2048 // Sets the threshold to Gzip responses at 2k (2048 bytes)
},
cors: {
origin: '*' // Set the `Access-Control-Allow-Origin` header to be `*`
},
debug: {
name: 'worker' // Set the debug logger name
},
helmet: {
noCache: true, // Sets the `Cache-Control` headers to prevent caching
frameguard: {
action: 'deny' // Set the `X-Frame-Options' header to be `DENY`
}
},
json: {
pretty: false // Disables pretty-printing
},
logger: {
format: 'dev' // Use the `dev` format of logging
}
}) Disabling middlewareEach of the middleware in koa-plus can be disabled individually by using the As an example, to reset const Koa = require('koa-plus')
const app = new Koa({
body: {
enabled: false
},
compress: {
enabled: false
},
cors: {
enabled: false
},
debug: {
enabled: false
},
etag: {
enabled: false
},
helmet: {
enabled: false
},
json: {
enabled: false
},
logger: {
enabled: false
},
requestId: {
enabled: false
},
responseTime: {
enabled: false
}
}) TestingTo run the tests locally, simply run
or
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论