wok-server 0.4.0 → 0.4.2
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.
|
@@ -161,7 +161,11 @@ class StaticHandler {
|
|
|
161
161
|
await this.endRespWithBuffer(response, file.bufferOrPath);
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
|
-
|
|
164
|
+
const path = file.bufferOrPath;
|
|
165
|
+
await new Promise((resolve, reject) => {
|
|
166
|
+
response.once('finish', resolve).once('error', reject);
|
|
167
|
+
(0, fs_1.createReadStream)(path).pipe((0, zlib_1.createGzip)()).pipe(response);
|
|
168
|
+
});
|
|
165
169
|
}
|
|
166
170
|
return true;
|
|
167
171
|
}
|
|
@@ -208,6 +212,9 @@ class StaticHandler {
|
|
|
208
212
|
return true;
|
|
209
213
|
}
|
|
210
214
|
async endRespWithBuffer(response, buffer) {
|
|
215
|
+
if (response.writableEnded || response.destroyed) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
211
218
|
await new Promise((resolve, reject) => {
|
|
212
219
|
response.write(buffer, err => {
|
|
213
220
|
if (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wok-server",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"packageManager": "pnpm@8.9.0",
|
|
5
5
|
"description": "一个基于 NodeJs 和 TypeScript 的后端框架,轻量级、克制、简洁。A lightweight, restrained, and concise backend framework based on Node.js and TypeScript.",
|
|
6
6
|
"scripts": {
|