waibu 1.1.21 → 1.2.0

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,15 +1,15 @@
1
- import collectRoutePathHandlers from '../lib/collect-route-path-handlers.js'
1
+ import collectRoutePathHandlers from './lib/collect-route-path-handlers.js'
2
2
  import fastify from 'fastify'
3
- import appHook from '../lib/app-hook.js'
4
- import routeHook from '../lib/webapp-scope/route-hook.js'
5
- import logRoutes from '../lib/log-routes.js'
6
- import { boot } from '../lib/app.js'
3
+ import appHook from './lib/app-hook.js'
4
+ import routeHook from './lib/webapp-scope/route-hook.js'
5
+ import logRoutes from './lib/log-routes.js'
6
+ import { boot } from './lib/app.js'
7
7
  import sensible from '@fastify/sensible'
8
8
  import noIcon from 'fastify-no-icon'
9
9
  import underPressure from '@fastify/under-pressure'
10
- import handleForward from '../lib/handle-forward.js'
11
- import handleRedirect from '../lib/handle-redirect.js'
12
- import buildLocals from '../lib/build-locals.js'
10
+ import handleForward from './lib/handle-forward.js'
11
+ import handleRedirect from './lib/handle-redirect.js'
12
+ import buildLocals from './lib/build-locals.js'
13
13
  import queryString from 'query-string'
14
14
 
15
15
  async function factory (pkgName) {
@@ -64,7 +64,15 @@ async function factory (pkgName) {
64
64
  noIcon: true,
65
65
  underPressure: false,
66
66
  forwardOpts: {
67
- disableRequestLogging: true
67
+ disableRequestLogging: true,
68
+ undici: {
69
+ connections: 128,
70
+ pipelining: 1,
71
+ keepAliveTimeout: 60 * 1000,
72
+ tls: {
73
+ rejectUnauthorized: false
74
+ }
75
+ }
68
76
  }
69
77
  }
70
78
  this.escapeChars = {
@@ -249,7 +257,8 @@ async function factory (pkgName) {
249
257
  }
250
258
 
251
259
  routePath = (name = '', options = {}) => {
252
- const { defaultsDeep, getPlugin } = this.app.bajo
260
+ const { getPlugin } = this.app.bajo
261
+ const { defaultsDeep } = this.lib.aneka
253
262
  const { isEmpty, get, trimEnd, trimStart } = this.lib._
254
263
  const { breakNsPath } = this.app.bajo
255
264
  const { query = {}, base = 'waibu', params = {}, guessHost } = options
@@ -298,7 +307,7 @@ async function factory (pkgName) {
298
307
  }
299
308
 
300
309
  unescapeBlock = (content, start, end, startReplacer, endReplacer) => {
301
- const { extractText } = this.app.bajo
310
+ const { extractText } = this.lib.aneka
302
311
  const { result } = extractText(content, start, end)
303
312
  if (result.length === 0) return content
304
313
  const unescaped = this.unescape(result)
@@ -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) {
@@ -15,13 +15,11 @@ async function handleForward (ctx) {
15
15
  const options = defaultsDeep({ base }, this.config.forwardOpts)
16
16
  await ctx.register(replyFrom, options)
17
17
 
18
- ctx.decorateReply('forwardTo', async function (url, options = {}) {
19
- if (url.startsWith('http')) this.redirectTo(url)
20
- else {
21
- this.from(me.routePath(url, options), {
22
- rewriteHeaders
23
- })
24
- }
18
+ ctx.decorateReply('forwardTo', function (url, options = {}) {
19
+ if (url.startsWith('http')) return this.redirectTo(url)
20
+ this.from(me.routePath(url, options), {
21
+ rewriteHeaders
22
+ })
25
23
  return this
26
24
  })
27
25
  }
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.21",
3
+ "version": "1.2.0",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {
File without changes
File without changes