waibu 2.17.0 → 2.18.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.
package/index.js
CHANGED
|
@@ -394,10 +394,9 @@ async function factory (pkgName) {
|
|
|
394
394
|
* @returns {(Object|Array)} - Returns object if ```returnDir``` is ```true```, array of files otherwise
|
|
395
395
|
*/
|
|
396
396
|
getUploadedFiles = async (reqId, fileUrl = false, returnDir = false) => {
|
|
397
|
-
const { getPluginDataDir } = this.app.bajo
|
|
398
397
|
const { resolvePath } = this.app.lib.aneka
|
|
399
398
|
const { fastGlob } = this.app.lib
|
|
400
|
-
const dir = `${getPluginDataDir(this.ns)}/upload/${reqId}`
|
|
399
|
+
const dir = `${this.app.getPluginDataDir(this.ns)}/upload/${reqId}`
|
|
401
400
|
const result = await fastGlob(`${dir}/*`)
|
|
402
401
|
if (!fileUrl) return returnDir ? { dir, files: result } : result
|
|
403
402
|
const files = result.map(f => resolvePath(f, true))
|
|
@@ -471,13 +470,12 @@ async function factory (pkgName) {
|
|
|
471
470
|
* @returns {string}
|
|
472
471
|
*/
|
|
473
472
|
routePath = (name = '', options = {}) => {
|
|
474
|
-
const { getPlugin } = this.app.bajo
|
|
475
473
|
const { defaultsDeep } = this.app.lib.aneka
|
|
476
474
|
const { isEmpty, get, trimEnd, trimStart } = this.app.lib._
|
|
477
475
|
const { breakNsPath } = this.app.bajo
|
|
478
476
|
const { query = {}, ns = this.ns, params = {}, guessHost, defaults = {}, uriEncoded } = options
|
|
479
477
|
|
|
480
|
-
const plugin = getPlugin(ns)
|
|
478
|
+
const plugin = this.app.getPlugin(ns)
|
|
481
479
|
const cfg = plugin.config ?? {}
|
|
482
480
|
let info = {}
|
|
483
481
|
const neg = name[0] === '!'
|
package/lib/handle-not-found.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export function writeHtml (req, reply, tpl, payload) {
|
|
2
|
-
const { getPluginFile } = this.app.bajo
|
|
3
2
|
const { fs } = this.app.lib
|
|
4
3
|
const { template } = this.app.lib._
|
|
5
4
|
reply.header('Content-Type', 'text/html')
|
|
6
5
|
reply.header('Content-Language', req.lang)
|
|
7
|
-
const file = getPluginFile(tpl)
|
|
6
|
+
const file = this.app.getPluginFile(tpl)
|
|
8
7
|
const content = fs.readFileSync(file, 'utf8')
|
|
9
8
|
const compiled = template(content)
|
|
10
9
|
return compiled(payload)
|
|
@@ -13,9 +13,8 @@ function normalizeValue (value) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async function onFileHandler () {
|
|
16
|
-
const { getPluginDataDir } = this.app.bajo
|
|
17
16
|
const { fs } = this.app.lib
|
|
18
|
-
const dir = `${getPluginDataDir('waibu')}/upload`
|
|
17
|
+
const dir = `${this.app.getPluginDataDir('waibu')}/upload`
|
|
19
18
|
return async function (part) {
|
|
20
19
|
// 'this' is the fastify context here
|
|
21
20
|
const filePath = `${dir}/${this.id}/${part.fieldname}@${part.filename}`
|
package/package.json
CHANGED