@server/next 0.49.2 → 0.49.3
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.d.ts +3 -2
- package/index.js +26 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -22,11 +22,12 @@ type BucketFile = {
|
|
|
22
22
|
stream(opts?: ReadOptions): ReadableStream;
|
|
23
23
|
slice?(start: number, end?: number): BucketFile;
|
|
24
24
|
bytes(opts?: ReadOptions): Promise<Uint8Array>;
|
|
25
|
-
remove(opts?: ReadOptions): Promise<unknown>;
|
|
25
|
+
remove?(opts?: ReadOptions): Promise<unknown>;
|
|
26
|
+
delete?(opts?: ReadOptions): Promise<unknown>;
|
|
26
27
|
};
|
|
27
28
|
type Bucket = {
|
|
28
29
|
file(name: string): BucketFile;
|
|
29
|
-
create(content: string | Buffer | ReadableStream, options?: {
|
|
30
|
+
create?(content: string | Buffer | ReadableStream, options?: {
|
|
30
31
|
type?: string;
|
|
31
32
|
} & ReadOptions): Promise<BucketFile>;
|
|
32
33
|
folder?(prefix: string): Bucket;
|
package/index.js
CHANGED
|
@@ -2395,6 +2395,18 @@ async function socketUser(app, headers2, cookies2) {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
|
|
2397
2397
|
// src/body/bodyParts.ts
|
|
2398
|
+
var extByMime = {};
|
|
2399
|
+
for (const ext in mimes_default) extByMime[mimes_default[ext].split(";")[0].trim()] = ext;
|
|
2400
|
+
function keyFor(type2) {
|
|
2401
|
+
const ext = extByMime[type2.split(";")[0].trim()];
|
|
2402
|
+
return `${createId()}${ext ? `.${ext}` : ""}`;
|
|
2403
|
+
}
|
|
2404
|
+
async function discard(file2) {
|
|
2405
|
+
try {
|
|
2406
|
+
await (file2.remove ? file2.remove() : file2.delete?.());
|
|
2407
|
+
} catch {
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2398
2410
|
var asIterable = (s) => s;
|
|
2399
2411
|
function getMatching(string, regex) {
|
|
2400
2412
|
const matches2 = string.match(regex);
|
|
@@ -2455,6 +2467,7 @@ async function abortFile(part, error) {
|
|
|
2455
2467
|
});
|
|
2456
2468
|
} catch {
|
|
2457
2469
|
}
|
|
2470
|
+
if (part.opened.handle) await discard(part.opened.handle);
|
|
2458
2471
|
}
|
|
2459
2472
|
throw error;
|
|
2460
2473
|
}
|
|
@@ -2493,10 +2506,21 @@ function openFile(part) {
|
|
|
2493
2506
|
controller = c;
|
|
2494
2507
|
}
|
|
2495
2508
|
});
|
|
2509
|
+
const write = { type: type2, signal: part.signal };
|
|
2510
|
+
if (part.bucket.create) {
|
|
2511
|
+
part.opened = {
|
|
2512
|
+
type: type2,
|
|
2513
|
+
controller,
|
|
2514
|
+
write: part.bucket.create(readable, write)
|
|
2515
|
+
};
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
const handle = part.bucket.file(keyFor(type2));
|
|
2496
2519
|
part.opened = {
|
|
2497
2520
|
type: type2,
|
|
2498
2521
|
controller,
|
|
2499
|
-
|
|
2522
|
+
handle,
|
|
2523
|
+
write: handle.write(readable, write).then(() => handle)
|
|
2500
2524
|
};
|
|
2501
2525
|
}
|
|
2502
2526
|
async function feedPart(part, data) {
|
|
@@ -2543,8 +2567,7 @@ async function endPart(part, body) {
|
|
|
2543
2567
|
const file2 = await opened.write;
|
|
2544
2568
|
const { minSize } = part.limits;
|
|
2545
2569
|
if (minSize != null && part.size < parseBytes(minSize)) {
|
|
2546
|
-
await file2
|
|
2547
|
-
});
|
|
2570
|
+
await discard(file2);
|
|
2548
2571
|
throw errors_default.UPLOAD_TOO_SMALL({
|
|
2549
2572
|
name: part.filename,
|
|
2550
2573
|
size: String(part.size),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@server/next",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.3",
|
|
4
4
|
"description": "A fully-fledged web server with routing, file uploads, sessions, static files, schema validation, websockets, testing, etc.",
|
|
5
5
|
"homepage": "https://server-js.com/",
|
|
6
6
|
"repository": "github:franciscop/server-next",
|