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.
@@ -1,7 +1,7 @@
1
1
  import replyFrom from '@fastify/reply-from'
2
2
 
3
3
  async function handleForward (ctx) {
4
- const { defaultsDeep } = this.app.bajo
4
+ const { defaultsDeep } = this.lib.aneka
5
5
  const me = this
6
6
 
7
7
  function rewriteHeaders (headers, req) {
package/lib/home.js CHANGED
@@ -1,5 +1,6 @@
1
1
  async function home () {
2
- const { defaultsDeep, callHandler } = this.app.bajo
2
+ const { callHandler } = this.app.bajo
3
+ const { defaultsDeep } = this.lib.aneka
3
4
  const { isString, pick } = this.lib._
4
5
  const config = this.getConfig()
5
6
  if (config.home) {
@@ -1,7 +1,7 @@
1
1
  import compress from '@fastify/compress'
2
2
 
3
3
  async function handleCompress (ctx, options = {}) {
4
- const { defaultsDeep } = this.app.bajo
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.app.bajo
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.app.bajo
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 { defaultsDeep, importPkg, isSet } = this.app.bajo
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.app.bajo
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugin/factory.js CHANGED
@@ -249,7 +249,8 @@ async function factory (pkgName) {
249
249
  }
250
250
 
251
251
  routePath = (name = '', options = {}) => {
252
- const { defaultsDeep, getPlugin } = this.app.bajo
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.app.bajo
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)