waibu 1.1.20 → 1.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/handle-forward.js +1 -1
- package/lib/home.js +2 -1
- package/lib/webapp-scope/handle-compress.js +1 -1
- package/lib/webapp-scope/handle-cors.js +1 -1
- package/lib/webapp-scope/handle-helmet.js +1 -1
- package/lib/webapp-scope/handle-multipart-body.js +2 -1
- package/lib/webapp-scope/handle-rate-limit.js +1 -1
- package/package.json +1 -1
- package/plugin/factory.js +4 -3
package/lib/handle-forward.js
CHANGED
package/lib/home.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import compress from '@fastify/compress'
|
|
2
2
|
|
|
3
3
|
async function handleCompress (ctx, options = {}) {
|
|
4
|
-
const { defaultsDeep } = this.
|
|
4
|
+
const { defaultsDeep } = this.lib.aneka
|
|
5
5
|
if (options === false) return this.log.warn('middlewareDisabled%s', 'compress')
|
|
6
6
|
const opts = defaultsDeep(options, this.app.waibu.config.compress)
|
|
7
7
|
await ctx.register(compress, opts)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cors from '@fastify/cors'
|
|
2
2
|
|
|
3
3
|
async function handleCors (ctx, options = {}) {
|
|
4
|
-
const { defaultsDeep } = this.
|
|
4
|
+
const { defaultsDeep } = this.lib.aneka
|
|
5
5
|
if (options === false) return this.log.warn('middlewareDisabled%s', 'cors')
|
|
6
6
|
const opts = defaultsDeep(options, this.app.waibu.config.cors)
|
|
7
7
|
await ctx.register(cors, opts)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import helmet from '@fastify/helmet'
|
|
2
2
|
|
|
3
3
|
async function handleHelmet (ctx, options = {}) {
|
|
4
|
-
const { defaultsDeep } = this.
|
|
4
|
+
const { defaultsDeep } = this.lib.aneka
|
|
5
5
|
if (options === false) return this.log.warn('middlewareDisabled%s', 'helmet')
|
|
6
6
|
const opts = defaultsDeep(options, this.app.waibu.config.helmet)
|
|
7
7
|
await ctx.register(helmet, opts)
|
|
@@ -17,7 +17,8 @@ async function onFileHandler () {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async function handleMultipartBody (ctx, options = {}) {
|
|
20
|
-
const {
|
|
20
|
+
const { importPkg } = this.app.bajo
|
|
21
|
+
const { defaultsDeep, isSet } = this.lib.aneka
|
|
21
22
|
const { isArray, map, trim, isPlainObject, isEmpty } = this.lib._
|
|
22
23
|
const parseVar = await importPkg('bajo:dotenv-parse-variables')
|
|
23
24
|
if (options === false) return this.log.warn('middlewareDisabled%s', 'multipart')
|
|
@@ -2,7 +2,7 @@ import rateLimit from '@fastify/rate-limit'
|
|
|
2
2
|
|
|
3
3
|
async function handleRateLimit (ctx, options = {}) {
|
|
4
4
|
const { cloneDeep } = this.lib._
|
|
5
|
-
const { defaultsDeep } = this.
|
|
5
|
+
const { defaultsDeep } = this.lib.aneka
|
|
6
6
|
if (options === false) return this.log.warn('middlewareDisabled%s', 'rateLimit')
|
|
7
7
|
const opts = defaultsDeep(options, this.app.waibu.config.rateLimit)
|
|
8
8
|
await ctx.register(rateLimit, cloneDeep(opts))
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -249,7 +249,8 @@ async function factory (pkgName) {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
routePath = (name = '', options = {}) => {
|
|
252
|
-
const {
|
|
252
|
+
const { getPlugin } = this.app.bajo
|
|
253
|
+
const { defaultsDeep } = this.lib.aneka
|
|
253
254
|
const { isEmpty, get, trimEnd, trimStart } = this.lib._
|
|
254
255
|
const { breakNsPath } = this.app.bajo
|
|
255
256
|
const { query = {}, base = 'waibu', params = {}, guessHost } = options
|
|
@@ -273,7 +274,7 @@ async function factory (pkgName) {
|
|
|
273
274
|
let url = info.path
|
|
274
275
|
const langDetector = get(cfg, 'intl.detectors', [])
|
|
275
276
|
if (info.ns) url = trimEnd(langDetector.includes('path') ? `/${params.lang ?? ''}${this.routeDir(info.ns)}${info.path}` : `${this.routeDir(info.ns)}${info.path}`, '/')
|
|
276
|
-
url = url.split('/').map(u => encodeURI(u)).join('/')
|
|
277
|
+
if (options.uriEncoded) url = url.split('/').map(u => encodeURI(u)).join('/')
|
|
277
278
|
info.qs = defaultsDeep({}, query, info.qs)
|
|
278
279
|
if (!isEmpty(info.qs)) url += '?' + this.qs.stringify(info.qs)
|
|
279
280
|
if (!url.startsWith('http') && guessHost) url = `http://${this.config.server.host}:${this.config.server.port}/${trimStart(url, '/')}`
|
|
@@ -298,7 +299,7 @@ async function factory (pkgName) {
|
|
|
298
299
|
}
|
|
299
300
|
|
|
300
301
|
unescapeBlock = (content, start, end, startReplacer, endReplacer) => {
|
|
301
|
-
const { extractText } = this.
|
|
302
|
+
const { extractText } = this.lib.aneka
|
|
302
303
|
const { result } = extractText(content, start, end)
|
|
303
304
|
if (result.length === 0) return content
|
|
304
305
|
const unescaped = this.unescape(result)
|