owebjs 1.2.1 → 1.2.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.
@@ -3,24 +3,24 @@ import {
3
3
  } from "../chunk-NH24FRB3.js";
4
4
  import fs from "node:fs";
5
5
  import nodePath from "node:path";
6
- var ChunkUploadStatusCode;
7
- (function(ChunkUploadStatusCode2) {
8
- ChunkUploadStatusCode2[ChunkUploadStatusCode2["Success"] = 200] = "Success";
9
- ChunkUploadStatusCode2[ChunkUploadStatusCode2["FileTooLarge"] = 413] = "FileTooLarge";
10
- ChunkUploadStatusCode2[ChunkUploadStatusCode2["ChunkTooLarge"] = 413] = "ChunkTooLarge";
11
- ChunkUploadStatusCode2[ChunkUploadStatusCode2["InvalidChunk"] = 400] = "InvalidChunk";
12
- })(ChunkUploadStatusCode || (ChunkUploadStatusCode = {}));
6
+ var ChunkUploadStatus;
7
+ (function(ChunkUploadStatus2) {
8
+ ChunkUploadStatus2["Success"] = "SUCCESS";
9
+ ChunkUploadStatus2["FileTooLarge"] = "FILE_TOO_LARGE";
10
+ ChunkUploadStatus2["ChunkTooLarge"] = "CHUNK_TOO_LARGE";
11
+ ChunkUploadStatus2["InvalidChunk"] = "INVALID_CHUNK";
12
+ })(ChunkUploadStatus || (ChunkUploadStatus = {}));
13
13
  async function ChunkUpload(file, options) {
14
14
  const { buffer, fileName, currentChunk, totalChunks } = file;
15
15
  const { path, maxChunkSize, maxFileSize } = options;
16
16
  if (typeof currentChunk !== "number" || typeof totalChunks !== "number" || currentChunk < 1 || totalChunks < 1 || currentChunk > totalChunks) {
17
17
  return {
18
- statusCode: ChunkUploadStatusCode.InvalidChunk
18
+ status: ChunkUploadStatus.InvalidChunk
19
19
  };
20
20
  }
21
21
  if (buffer.length > maxChunkSize) {
22
22
  return {
23
- statusCode: ChunkUploadStatusCode.ChunkTooLarge
23
+ status: ChunkUploadStatus.ChunkTooLarge
24
24
  };
25
25
  }
26
26
  const filePath = nodePath.join(path, fileName);
@@ -39,11 +39,11 @@ async function ChunkUpload(file, options) {
39
39
  if (typeof maxFileSize === "number" && fileSize > maxFileSize) {
40
40
  fs.unlinkSync(filePath);
41
41
  return {
42
- statusCode: ChunkUploadStatusCode.FileTooLarge
42
+ status: ChunkUploadStatus.FileTooLarge
43
43
  };
44
44
  }
45
45
  return {
46
- statusCode: ChunkUploadStatusCode.Success,
46
+ status: ChunkUploadStatus.Success,
47
47
  uploadCompleted: true
48
48
  };
49
49
  } else if (currentChunk === 1) {
@@ -52,12 +52,12 @@ async function ChunkUpload(file, options) {
52
52
  fs.appendFileSync(chunkPath, buffer);
53
53
  }
54
54
  return {
55
- statusCode: ChunkUploadStatusCode.Success,
55
+ status: ChunkUploadStatus.Success,
56
56
  currentChunk
57
57
  };
58
58
  }
59
59
  __name(ChunkUpload, "ChunkUpload");
60
60
  export {
61
61
  ChunkUpload,
62
- ChunkUploadStatusCode
62
+ ChunkUploadStatus
63
63
  };
@@ -19,16 +19,16 @@ interface ChunkUploadOptions {
19
19
  maxFileSize?: number;
20
20
  }
21
21
  interface ChunkUploadResult {
22
- statusCode: ChunkUploadStatusCode;
22
+ status: ChunkUploadStatus;
23
23
  uploadCompleted?: true;
24
24
  currentChunk?: number;
25
25
  }
26
- declare enum ChunkUploadStatusCode {
27
- Success = 200,
28
- FileTooLarge = 413,
29
- ChunkTooLarge = 413,
30
- InvalidChunk = 400
26
+ declare enum ChunkUploadStatus {
27
+ Success = "SUCCESS",
28
+ FileTooLarge = "FILE_TOO_LARGE",
29
+ ChunkTooLarge = "CHUNK_TOO_LARGE",
30
+ InvalidChunk = "INVALID_CHUNK"
31
31
  }
32
32
  declare function ChunkUpload(file: FileData, options: ChunkUploadOptions): Promise<ChunkUploadResult>;
33
33
 
34
- export { ChunkUpload, ChunkUploadOptions, ChunkUploadResult, ChunkUploadStatusCode, FileData };
34
+ export { ChunkUpload, ChunkUploadOptions, ChunkUploadResult, ChunkUploadStatus, FileData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owebjs",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Flexible handler that built on top of Fastify",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",