@lsby/net-core-file-upload 0.1.9

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.
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ \u6587\u4EF6\u4E0A\u4F20\u63D2\u4EF6: () => \u6587\u4EF6\u4E0A\u4F20\u63D2\u4EF6
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+ var import_express_fileupload = __toESM(require("express-fileupload"), 1);
37
+ var import_zod = require("zod");
38
+ var import_net_core = require("@lsby/net-core");
39
+ var \u7C7B\u578B\u63CF\u8FF0 = import_zod.z.object({
40
+ files: import_zod.z.object({
41
+ name: import_zod.z.string(),
42
+ encoding: import_zod.z.string(),
43
+ mimetype: import_zod.z.string(),
44
+ data: import_zod.z.instanceof(Buffer),
45
+ tempFilePath: import_zod.z.string(),
46
+ truncated: import_zod.z.boolean(),
47
+ size: import_zod.z.number(),
48
+ md5: import_zod.z.string()
49
+ }).array()
50
+ });
51
+ var \u6587\u4EF6\u4E0A\u4F20\u63D2\u4EF6 = class extends import_net_core.\u63D2\u4EF6 {
52
+ constructor(opt) {
53
+ super(\u7C7B\u578B\u63CF\u8FF0, async (req, res) => {
54
+ await new Promise(
55
+ (resP, _rej) => (0, import_express_fileupload.default)({ limits: { fileSize: opt.\u6587\u4EF6\u6700\u5927\u5927\u5C0F } })(req, res, () => {
56
+ resP(null);
57
+ })
58
+ );
59
+ return {
60
+ files: Object.values(req.files)
61
+ };
62
+ });
63
+ }
64
+ };
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ \u6587\u4EF6\u4E0A\u4F20\u63D2\u4EF6
68
+ });
@@ -0,0 +1,62 @@
1
+ import { z } from 'zod';
2
+ import { 插件 as __ } from '@lsby/net-core';
3
+
4
+ declare var 类型描述: z.ZodObject<{
5
+ files: z.ZodArray<z.ZodObject<{
6
+ name: z.ZodString;
7
+ encoding: z.ZodString;
8
+ mimetype: z.ZodString;
9
+ data: z.ZodType<Buffer, z.ZodTypeDef, Buffer>;
10
+ tempFilePath: z.ZodString;
11
+ truncated: z.ZodBoolean;
12
+ size: z.ZodNumber;
13
+ md5: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ name: string;
16
+ encoding: string;
17
+ mimetype: string;
18
+ data: Buffer;
19
+ tempFilePath: string;
20
+ truncated: boolean;
21
+ size: number;
22
+ md5: string;
23
+ }, {
24
+ name: string;
25
+ encoding: string;
26
+ mimetype: string;
27
+ data: Buffer;
28
+ tempFilePath: string;
29
+ truncated: boolean;
30
+ size: number;
31
+ md5: string;
32
+ }>, "many">;
33
+ }, "strip", z.ZodTypeAny, {
34
+ files: {
35
+ name: string;
36
+ encoding: string;
37
+ mimetype: string;
38
+ data: Buffer;
39
+ tempFilePath: string;
40
+ truncated: boolean;
41
+ size: number;
42
+ md5: string;
43
+ }[];
44
+ }, {
45
+ files: {
46
+ name: string;
47
+ encoding: string;
48
+ mimetype: string;
49
+ data: Buffer;
50
+ tempFilePath: string;
51
+ truncated: boolean;
52
+ size: number;
53
+ md5: string;
54
+ }[];
55
+ }>;
56
+ declare class 文件上传插件 extends __<typeof 类型描述> {
57
+ constructor(opt: {
58
+ 文件最大大小: number;
59
+ });
60
+ }
61
+
62
+ export { 文件上传插件 };
@@ -0,0 +1,62 @@
1
+ import { z } from 'zod';
2
+ import { 插件 as __ } from '@lsby/net-core';
3
+
4
+ declare var 类型描述: z.ZodObject<{
5
+ files: z.ZodArray<z.ZodObject<{
6
+ name: z.ZodString;
7
+ encoding: z.ZodString;
8
+ mimetype: z.ZodString;
9
+ data: z.ZodType<Buffer, z.ZodTypeDef, Buffer>;
10
+ tempFilePath: z.ZodString;
11
+ truncated: z.ZodBoolean;
12
+ size: z.ZodNumber;
13
+ md5: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ name: string;
16
+ encoding: string;
17
+ mimetype: string;
18
+ data: Buffer;
19
+ tempFilePath: string;
20
+ truncated: boolean;
21
+ size: number;
22
+ md5: string;
23
+ }, {
24
+ name: string;
25
+ encoding: string;
26
+ mimetype: string;
27
+ data: Buffer;
28
+ tempFilePath: string;
29
+ truncated: boolean;
30
+ size: number;
31
+ md5: string;
32
+ }>, "many">;
33
+ }, "strip", z.ZodTypeAny, {
34
+ files: {
35
+ name: string;
36
+ encoding: string;
37
+ mimetype: string;
38
+ data: Buffer;
39
+ tempFilePath: string;
40
+ truncated: boolean;
41
+ size: number;
42
+ md5: string;
43
+ }[];
44
+ }, {
45
+ files: {
46
+ name: string;
47
+ encoding: string;
48
+ mimetype: string;
49
+ data: Buffer;
50
+ tempFilePath: string;
51
+ truncated: boolean;
52
+ size: number;
53
+ md5: string;
54
+ }[];
55
+ }>;
56
+ declare class 文件上传插件 extends __<typeof 类型描述> {
57
+ constructor(opt: {
58
+ 文件最大大小: number;
59
+ });
60
+ }
61
+
62
+ export { 文件上传插件 };
@@ -0,0 +1,33 @@
1
+ // src/index.ts
2
+ import fileUpload from "express-fileupload";
3
+ import { z } from "zod";
4
+ import { \u63D2\u4EF6 } from "@lsby/net-core";
5
+ var \u7C7B\u578B\u63CF\u8FF0 = z.object({
6
+ files: z.object({
7
+ name: z.string(),
8
+ encoding: z.string(),
9
+ mimetype: z.string(),
10
+ data: z.instanceof(Buffer),
11
+ tempFilePath: z.string(),
12
+ truncated: z.boolean(),
13
+ size: z.number(),
14
+ md5: z.string()
15
+ }).array()
16
+ });
17
+ var \u6587\u4EF6\u4E0A\u4F20\u63D2\u4EF6 = class extends \u63D2\u4EF6 {
18
+ constructor(opt) {
19
+ super(\u7C7B\u578B\u63CF\u8FF0, async (req, res) => {
20
+ await new Promise(
21
+ (resP, _rej) => fileUpload({ limits: { fileSize: opt.\u6587\u4EF6\u6700\u5927\u5927\u5C0F } })(req, res, () => {
22
+ resP(null);
23
+ })
24
+ );
25
+ return {
26
+ files: Object.values(req.files)
27
+ };
28
+ });
29
+ }
30
+ };
31
+ export {
32
+ \u6587\u4EF6\u4E0A\u4F20\u63D2\u4EF6
33
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@lsby/net-core-file-upload",
3
+ "version": "0.1.9",
4
+ "type": "module",
5
+ "exports": {
6
+ "require": "./dist/cjs/index.cjs",
7
+ "import": "./dist/esm/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build:all": "npm run build:cjs && npm run build:esm",
14
+ "build:cjs": "tsup src/**/*.ts --format cjs --clean --dts -d dist/cjs",
15
+ "build:esm": "tsup src/**/*.ts --format esm --clean --dts -d dist/esm",
16
+ "check:all": "npm run check:format && npm run check:lint && npm run check:type",
17
+ "check:format": "prettier --write .",
18
+ "check:lint": "eslint . --fix",
19
+ "check:type": "tsc --noEmit",
20
+ "check:type:watch": "tsc --noEmit -w",
21
+ "pub:public": "npm run check:all && npm run test:base && npm run build:all && bumpp && npm publish --access public",
22
+ "test:base": "npm run check:all && vitest run",
23
+ "test:coverage": "npm run check:all && vitest run --coverage && open-cli ./coverage/index.html"
24
+ },
25
+ "dependencies": {
26
+ "express-fileupload": "^1.5.1"
27
+ },
28
+ "devDependencies": {
29
+ "@ianvs/prettier-plugin-sort-imports": "^4.2.1",
30
+ "@lsby/eslint-config": "^0.1.0",
31
+ "@types/express-fileupload": "^1.5.0",
32
+ "@types/node": "^20.12.10",
33
+ "@vitest/coverage-v8": "^2.0.2",
34
+ "bumpp": "^9.4.1",
35
+ "open-cli": "^8.0.0",
36
+ "prettier": "3.2.5",
37
+ "prettier-plugin-packagejson": "^2.5.0",
38
+ "tsup": "^8.0.2",
39
+ "typescript": "^5.4.5",
40
+ "vitest": "^2.0.2"
41
+ },
42
+ "peerDependencies": {
43
+ "@lsby/net-core": "^0.6.0",
44
+ "@lsby/ts-fp-data": "^0.2.4",
45
+ "zod": "3.23.8"
46
+ },
47
+ "packageManager": "pnpm@9.7.1+sha512.faf344af2d6ca65c4c5c8c2224ea77a81a5e8859cbc4e06b1511ddce2f0151512431dd19e6aff31f2c6a8f5f2aced9bd2273e1fed7dd4de1868984059d2c4247"
48
+ }