waibu-mpa 1.2.9 → 1.2.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-mpa",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "description": "MPA support for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,23 +1,20 @@
1
- import path from 'path'
2
-
3
- async function logo (req, reply) {
4
- const { importPkg } = this.app.bajo
5
- const mime = await importPkg('waibu:mime')
1
+ async function resolveFile (req) {
6
2
  const { getPlugin } = this.app.bajo
7
3
  const { camelCase } = this.lib._
8
- const { fastGlob, fs } = this.lib
4
+ const { fastGlob } = this.lib
9
5
  const id = camelCase(req.params.id)
10
6
  const plugin = getPlugin(id)
11
7
  let type = ''
12
8
  if (req.query.type) type = `-${req.query.type}`
13
9
  const files = await fastGlob(`${plugin.dir.pkg}/logo${type}.*`)
14
10
  if (files.length === 0) throw this.error('_notFound')
15
- const file = files[0]
16
- const mimeType = mime.getType(path.extname(file))
17
- reply.header('Content-Type', mimeType)
18
- const stream = fs.createReadStream(file)
19
- reply.send(stream)
20
- return reply
11
+ return files[0]
12
+ }
13
+
14
+ async function logo (req, reply) {
15
+ const { importModule } = this.app.bajo
16
+ const handler = await importModule('waibu:/lib/handle-download.js')
17
+ return await handler.call(this, resolveFile, req, reply)
21
18
  }
22
19
 
23
20
  export default logo