koa-files 3.1.9 → 3.1.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/cjs/Service.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
@@ -136,8 +136,12 @@ class Service {
136
136
  if (this.isIgnore(path$2)) {
137
137
  return false;
138
138
  }
139
+ // Get options.
140
+ const { options } = this;
141
+ // Get file system.
142
+ const { fs } = options;
139
143
  // File stats.
140
- const stats = await fs$1.stat(this.options.fs, path$2);
144
+ const stats = await fs$1.stat(fs, path$2);
141
145
  // Check file stats.
142
146
  if (
143
147
  // File not exist (404 | 500).
@@ -190,7 +194,7 @@ class Service {
190
194
  return context.throw(400);
191
195
  }
192
196
  // Get stream options.
193
- const { fs, highWaterMark } = this.options;
197
+ const { highWaterMark } = options;
194
198
  // Set response body.
195
199
  context.body = new stream.FileReadStream(path$2, ranges, { fs, highWaterMark });
196
200
  // File found.
package/cjs/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
package/cjs/utils/fs.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
package/esm/Service.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
@@ -127,8 +127,12 @@ class Service {
127
127
  if (this.isIgnore(path)) {
128
128
  return false;
129
129
  }
130
+ // Get options.
131
+ const { options } = this;
132
+ // Get file system.
133
+ const { fs } = options;
130
134
  // File stats.
131
- const stats = await stat(this.options.fs, path);
135
+ const stats = await stat(fs, path);
132
136
  // Check file stats.
133
137
  if (
134
138
  // File not exist (404 | 500).
@@ -181,7 +185,7 @@ class Service {
181
185
  return context.throw(400);
182
186
  }
183
187
  // Get stream options.
184
- const { fs, highWaterMark } = this.options;
188
+ const { highWaterMark } = options;
185
189
  // Set response body.
186
190
  context.body = new FileReadStream(path, ranges, { fs, highWaterMark });
187
191
  // File found.
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
package/esm/utils/fs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
package/esm/utils/hash.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
package/esm/utils/http.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
package/esm/utils/path.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package koa-files
3
3
  * @license MIT
4
- * @version 3.1.9
4
+ * @version 3.1.10
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A static files serving middleware for koa.
7
7
  * @see https://github.com/nuintun/koa-files#readme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koa-files",
3
- "version": "3.1.9",
3
+ "version": "3.1.10",
4
4
  "description": "A static files serving middleware for koa.",
5
5
  "type": "module",
6
6
  "main": "cjs/index.cjs",
@@ -26,8 +26,8 @@ export interface Options {
26
26
  * @class Service
27
27
  */
28
28
  export default class Service {
29
- private root;
30
- private options;
29
+ private readonly root;
30
+ private readonly options;
31
31
  /**
32
32
  * @constructor
33
33
  * @description Create file service.
@@ -18,9 +18,9 @@ interface Callback {
18
18
  (error?: Error | null): void;
19
19
  }
20
20
  export declare class FileReadStream extends Readable {
21
- private fs;
22
- private path;
23
- private ranges;
21
+ private readonly fs;
22
+ private readonly path;
23
+ private readonly ranges;
24
24
  private bytesRead;
25
25
  private fd;
26
26
  private reading;