@kne/fastify-aliyun 1.1.0 → 1.1.1

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
@@ -18,6 +18,9 @@ module.exports = fp(
18
18
  endpoint: 'http://nls-gateway-cn-shanghai.aliyuncs.com/stream/v1/tts'
19
19
  }
20
20
  },
21
+ oss: {
22
+ baseDir: 'default'
23
+ },
21
24
  prefix: `/api/v${packageJson.version.split('.')[0]}/aliyun`,
22
25
  createAuthenticate: () => {
23
26
  return [];
@@ -3,7 +3,7 @@ const { RPCClient } = require('@alicloud/pop-core');
3
3
  const fetch = require('node-fetch');
4
4
  const fileType = require('file-type');
5
5
  module.exports = fp(async (fastify, options) => {
6
- const { servers } = fastify.aliyun;
6
+ const { services } = fastify.aliyun;
7
7
  const getToken = async () => {
8
8
  if (options.cache.has('nls:token')) {
9
9
  const Token = options.cache.get('nls:token');
@@ -51,7 +51,7 @@ module.exports = fp(async (fastify, options) => {
51
51
  file: { toBuffer: () => buffer, filename: `${audioName || 'audio'}.${type.ext}`, mimetype: type.mime }
52
52
  });
53
53
  };
54
- servers.nls = {
54
+ services.nls = {
55
55
  getToken,
56
56
  tts
57
57
  };
@@ -2,7 +2,7 @@ const OSS = require('ali-oss');
2
2
  const fp = require('fastify-plugin');
3
3
 
4
4
  module.exports = fp(async (fastify, options) => {
5
- const { servers } = fastify.aliyun;
5
+ const { services } = fastify.aliyun;
6
6
  const client = new OSS({
7
7
  region: options.oss.region,
8
8
  accessKeyId: options.oss.accessKeyId,
@@ -27,10 +27,11 @@ module.exports = fp(async (fastify, options) => {
27
27
  return client.signatureUrl(`${options.oss.baseDir}/${filename}`, { expires: expires || 3600 });
28
28
  };
29
29
 
30
- servers.oss = {
30
+ services.oss = {
31
31
  client,
32
32
  uploadFile,
33
33
  uploadFileStream,
34
- getFileLink
34
+ getFileLink,
35
+ downloadFile
35
36
  };
36
37
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-aliyun",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "对接阿里云服务",
5
5
  "main": "index.js",
6
6
  "scripts": {