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 +7 -3
- package/cjs/index.cjs +1 -1
- package/cjs/utils/fs.cjs +1 -1
- package/cjs/utils/hash.cjs +1 -1
- package/cjs/utils/http.cjs +1 -1
- package/cjs/utils/path.cjs +1 -1
- package/cjs/utils/stream.cjs +1 -1
- package/esm/Service.js +7 -3
- package/esm/index.js +1 -1
- package/esm/utils/fs.js +1 -1
- package/esm/utils/hash.js +1 -1
- package/esm/utils/http.js +1 -1
- package/esm/utils/path.js +1 -1
- package/esm/utils/stream.js +1 -1
- package/package.json +1 -1
- package/types/Service.d.ts +2 -2
- package/types/utils/stream.d.ts +3 -3
package/cjs/Service.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.1.
|
|
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(
|
|
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 {
|
|
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
package/cjs/utils/fs.cjs
CHANGED
package/cjs/utils/hash.cjs
CHANGED
package/cjs/utils/http.cjs
CHANGED
package/cjs/utils/path.cjs
CHANGED
package/cjs/utils/stream.cjs
CHANGED
package/esm/Service.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.1.
|
|
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(
|
|
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 {
|
|
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
package/esm/utils/fs.js
CHANGED
package/esm/utils/hash.js
CHANGED
package/esm/utils/http.js
CHANGED
package/esm/utils/path.js
CHANGED
package/esm/utils/stream.js
CHANGED
package/package.json
CHANGED
package/types/Service.d.ts
CHANGED
package/types/utils/stream.d.ts
CHANGED
|
@@ -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;
|