waibu 1.0.10 → 1.0.11
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/bajo/config.json +4 -0
- package/bajo/intl/en-US.json +2 -1
- package/bajo/intl/id.json +2 -1
- package/lib/webapp-scope/handle-compress.js +4 -2
- package/lib/webapp-scope/handle-cors.js +4 -2
- package/lib/webapp-scope/handle-helmet.js +4 -2
- package/lib/webapp-scope/handle-multipart-body.js +3 -2
- package/lib/webapp-scope/handle-rate-limit.js +4 -2
- package/package.json +1 -1
package/bajo/config.json
CHANGED
package/bajo/intl/en-US.json
CHANGED
|
@@ -10,5 +10,6 @@
|
|
|
10
10
|
"routeDisabled%s%s": "Route %s (%s) is disabled",
|
|
11
11
|
"rerouted%s%s": "Rerouted %s -> %s",
|
|
12
12
|
"bootSubApp%s": "Boot sub app: %s",
|
|
13
|
-
"routeNotFound%s%s": "Route '%s (%s)' not found"
|
|
13
|
+
"routeNotFound%s%s": "Route '%s (%s)' not found",
|
|
14
|
+
"middlewareDisabled%s": "Middleware '%s' is disabled"
|
|
14
15
|
}
|
package/bajo/intl/id.json
CHANGED
|
@@ -10,5 +10,6 @@
|
|
|
10
10
|
"routeDisabled%s%s": "Jalur %s (%s) dimatikan",
|
|
11
11
|
"rerouted%s%s": "Jalur dipindahkan %s -> %s",
|
|
12
12
|
"bootSubApp%s": "Boot sub app: %s",
|
|
13
|
-
"routeNotFound%s%s": "Jalur '%s (%s)' tidak ditemukan"
|
|
13
|
+
"routeNotFound%s%s": "Jalur '%s (%s)' tidak ditemukan",
|
|
14
|
+
"middlewareDisabled%s": "Middleware '%s' dimatikan"
|
|
14
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import compress from '@fastify/compress'
|
|
2
2
|
|
|
3
3
|
async function handleCompress (ctx, options = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const { defaultsDeep } = this.app.bajo
|
|
5
|
+
if (options === false) return this.log.warn('middlewareDisabled%s', 'compress')
|
|
6
|
+
const opts = defaultsDeep(options, this.app.waibu.config.compress)
|
|
7
|
+
await ctx.register(compress, opts)
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export default handleCompress
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import cors from '@fastify/cors'
|
|
2
2
|
|
|
3
3
|
async function handleCors (ctx, options = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const { defaultsDeep } = this.app.bajo
|
|
5
|
+
if (options === false) return this.log.warn('middlewareDisabled%s', 'cors')
|
|
6
|
+
const opts = defaultsDeep(options, this.app.waibu.config.cors)
|
|
7
|
+
await ctx.register(cors, opts)
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export default handleCors
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import helmet from '@fastify/helmet'
|
|
2
2
|
|
|
3
3
|
async function handleHelmet (ctx, options = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const { defaultsDeep } = this.app.bajo
|
|
5
|
+
if (options === false) return this.log.warn('middlewareDisabled%s', 'helmet')
|
|
6
|
+
const opts = defaultsDeep(options, this.app.waibu.config.helmet)
|
|
7
|
+
await ctx.register(helmet, opts)
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export default handleHelmet
|
|
@@ -7,7 +7,7 @@ const pump = promisify(pipeline)
|
|
|
7
7
|
async function onFileHandler () {
|
|
8
8
|
const { getPluginDataDir } = this.app.bajo
|
|
9
9
|
const { fs } = this.app.bajo.lib
|
|
10
|
-
const dir = `${getPluginDataDir(
|
|
10
|
+
const dir = `${getPluginDataDir('waibu')}/upload`
|
|
11
11
|
return async function (part) {
|
|
12
12
|
// 'this' is the fastify context here
|
|
13
13
|
const filePath = `${dir}/${this.id}/${part.fieldname}@${part.filename}`
|
|
@@ -20,7 +20,8 @@ async function handleMultipartBody (ctx, options = {}) {
|
|
|
20
20
|
const { defaultsDeep, importPkg, isSet } = this.app.bajo
|
|
21
21
|
const { isArray, map, trim, isPlainObject, isEmpty } = this.app.bajo.lib._
|
|
22
22
|
const parseVar = await importPkg('dotenv-parse-variables')
|
|
23
|
-
|
|
23
|
+
if (options === false) return this.log.warn('middlewareDisabled%s', 'multipart')
|
|
24
|
+
const opts = defaultsDeep(options, this.app.waibu.config.multipart)
|
|
24
25
|
const onFile = await onFileHandler.call(this)
|
|
25
26
|
opts.onFile = onFile
|
|
26
27
|
await ctx.register(multipart, opts)
|
|
@@ -2,8 +2,10 @@ import rateLimit from '@fastify/rate-limit'
|
|
|
2
2
|
|
|
3
3
|
async function handleRateLimit (ctx, options = {}) {
|
|
4
4
|
const { cloneDeep } = this.app.bajo.lib._
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const { defaultsDeep } = this.app.bajo
|
|
6
|
+
if (options === false) return this.log.warn('middlewareDisabled%s', 'rateLimit')
|
|
7
|
+
const opts = defaultsDeep(options, this.app.waibu.config.rateLimit)
|
|
8
|
+
await ctx.register(rateLimit, cloneDeep(opts))
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export default handleRateLimit
|