ismx-nexo-node-app 0.4.184 → 0.4.186
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.
|
@@ -44,6 +44,7 @@ class BusinessServer extends Business_1.default {
|
|
|
44
44
|
this.publish = this.publish.bind(this);
|
|
45
45
|
Promise.resolve().then(() => __importStar(require("express"))).then((e) => this.express = e.default);
|
|
46
46
|
Promise.resolve().then(() => __importStar(require("cors"))).then((e) => this.cors = e.default);
|
|
47
|
+
Promise.resolve().then(() => __importStar(require("multer"))).then((multer) => this.multer = multer);
|
|
47
48
|
Promise.resolve().then(() => __importStar(require("node:stream"))).then((e) => this.readable = e.default.Readable);
|
|
48
49
|
}
|
|
49
50
|
init() {
|
|
@@ -95,6 +96,7 @@ class BusinessServer extends Business_1.default {
|
|
|
95
96
|
case 'stream': return this.express.raw({ type: 'application/octet-stream', limit: '50mb' });
|
|
96
97
|
case 'image': return this.express.raw({ type: 'image/*', limit: '50mb' });
|
|
97
98
|
case 'audio': return this.express.raw({ type: 'audio/*', limit: '50mb' });
|
|
99
|
+
case 'multipart': return this.multer({ storage: this.multer.memoryStorage() }).array('bundle');
|
|
98
100
|
case '*': return this.express.raw({ type: () => true, limit: '50mb' });
|
|
99
101
|
default: return this.express.json();
|
|
100
102
|
}
|
|
@@ -169,27 +171,5 @@ class BusinessServer extends Business_1.default {
|
|
|
169
171
|
}
|
|
170
172
|
});
|
|
171
173
|
}
|
|
172
|
-
load(parent, path) {
|
|
173
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
/*
|
|
175
|
-
const { readdir } = await import('fs/promises');
|
|
176
|
-
const pathModule = await import('path');
|
|
177
|
-
const { fileURLToPath } = await import('url');
|
|
178
|
-
|
|
179
|
-
// @ts-ignore
|
|
180
|
-
const __dirname = pathModule.dirname(fileURLToPath(parent));
|
|
181
|
-
const servicesPath = pathModule.join(__dirname, path);
|
|
182
|
-
|
|
183
|
-
const files = await readdir(servicesPath);
|
|
184
|
-
for (const file of files) {
|
|
185
|
-
if (!file.endsWith('.ts') && !file.endsWith('.js')) continue;
|
|
186
|
-
const modulePath = pathModule.join(servicesPath, file);
|
|
187
|
-
const mod = await import(modulePath);
|
|
188
|
-
const ServiceClass = Object.values(mod)[0];
|
|
189
|
-
// @ts-ignore
|
|
190
|
-
const instance = new ServiceClass();
|
|
191
|
-
}*/
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
174
|
}
|
|
195
175
|
exports.default = BusinessServer;
|
|
@@ -10,11 +10,20 @@ export interface HttpRequest<T = any> {
|
|
|
10
10
|
query?: {
|
|
11
11
|
[key: string]: string;
|
|
12
12
|
};
|
|
13
|
+
multipart?: HttpMultipart[];
|
|
13
14
|
body?: T;
|
|
14
15
|
headers?: {
|
|
15
16
|
[key: string]: string;
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
export interface HttpMultipart {
|
|
20
|
+
fieldname: string;
|
|
21
|
+
originalname: string;
|
|
22
|
+
encoding?: string;
|
|
23
|
+
mimetype: string;
|
|
24
|
+
buffer: Buffer;
|
|
25
|
+
size: number;
|
|
26
|
+
}
|
|
18
27
|
export declare class HttpResponse<T = any> {
|
|
19
28
|
content: T;
|
|
20
29
|
httpCode?: number;
|
|
@@ -26,7 +35,7 @@ export declare class HttpResponse<T = any> {
|
|
|
26
35
|
static ko<T = any>(httpCode: number, content: T): HttpResponse<any>;
|
|
27
36
|
static do<T = any>(httpCode: number, content: T): HttpResponse<any>;
|
|
28
37
|
}
|
|
29
|
-
export type ServiceType = "json" | "xml" | 'stream' | 'image' | 'audio' | 'video' | '*';
|
|
38
|
+
export type ServiceType = "json" | "xml" | 'stream' | 'image' | 'audio' | 'video' | 'multipart' | '*';
|
|
30
39
|
export default abstract class Service<Req, Res> {
|
|
31
40
|
static readonly services: Service<any, any>[];
|
|
32
41
|
readonly method: string;
|
|
@@ -4,6 +4,7 @@ export default class BusinessServer extends Business {
|
|
|
4
4
|
private services;
|
|
5
5
|
private express;
|
|
6
6
|
private app;
|
|
7
|
+
private multer;
|
|
7
8
|
private cors;
|
|
8
9
|
private readable;
|
|
9
10
|
constructor();
|
|
@@ -22,5 +23,4 @@ export default class BusinessServer extends Business {
|
|
|
22
23
|
setOnEnd(listener: (request: HttpRequest, response: HttpResponse) => any): void;
|
|
23
24
|
private publish;
|
|
24
25
|
private run;
|
|
25
|
-
load(parent: string, path: string): Promise<void>;
|
|
26
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ismx-nexo-node-app",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.186",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rm -rf ./dist && npx tsc",
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
"author": "",
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@types/multer": "^2.0.0",
|
|
17
18
|
"esbuild": "^0.23.1"
|
|
18
19
|
},
|
|
19
20
|
"reqDependencies": {
|
|
20
21
|
"cors": "^2.8.5",
|
|
22
|
+
"multer": "^2.8.5",
|
|
21
23
|
"node-fetch": "^2.6.11",
|
|
22
24
|
"pg": "^8.11.0",
|
|
23
25
|
"ts-node": "8.10.1",
|
|
@@ -6,10 +6,20 @@ export interface HttpRequest<T = any> {
|
|
|
6
6
|
timestamp?: Date,
|
|
7
7
|
params?: { [key: string]: string },
|
|
8
8
|
query?: { [key: string]: string },
|
|
9
|
+
multipart?: HttpMultipart[] ,
|
|
9
10
|
body?: T,
|
|
10
11
|
headers?: { [key: string]: string },
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
export interface HttpMultipart {
|
|
15
|
+
fieldname: string,
|
|
16
|
+
originalname: string,
|
|
17
|
+
encoding?: string,
|
|
18
|
+
mimetype: string,
|
|
19
|
+
buffer: Buffer,
|
|
20
|
+
size: number,
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
export class HttpResponse<T = any> {
|
|
14
24
|
content: T = null!;
|
|
15
25
|
httpCode?: number;
|
|
@@ -36,7 +46,7 @@ export class HttpResponse<T = any> {
|
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
export type ServiceType = "json" | "xml" | 'stream' | 'image' | 'audio' | 'video' | '*';
|
|
49
|
+
export type ServiceType = "json" | "xml" | 'stream' | 'image' | 'audio' | 'video' | 'multipart' | '*';
|
|
40
50
|
export default abstract class Service<Req, Res>
|
|
41
51
|
{
|
|
42
52
|
public static readonly services: Service<any, any>[] = []
|
|
@@ -8,6 +8,7 @@ export default class BusinessServer extends Business
|
|
|
8
8
|
private express: any;
|
|
9
9
|
|
|
10
10
|
private app: any;
|
|
11
|
+
private multer: any;
|
|
11
12
|
private cors: any;
|
|
12
13
|
private readable: any;
|
|
13
14
|
|
|
@@ -16,7 +17,8 @@ export default class BusinessServer extends Business
|
|
|
16
17
|
this.publish = this.publish.bind(this);
|
|
17
18
|
|
|
18
19
|
import("express").then((e) => this.express = e.default);
|
|
19
|
-
import("cors").then((e) => this.cors = e.default)
|
|
20
|
+
import("cors").then((e) => this.cors = e.default);
|
|
21
|
+
import("multer").then((multer) => this.multer = multer);
|
|
20
22
|
import("node:stream").then((e) => this.readable = e.default.Readable)
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -83,6 +85,7 @@ export default class BusinessServer extends Business
|
|
|
83
85
|
case 'stream': return this.express.raw({ type: 'application/octet-stream', limit: '50mb' });
|
|
84
86
|
case 'image': return this.express.raw({ type: 'image/*', limit: '50mb' });
|
|
85
87
|
case 'audio': return this.express.raw({ type: 'audio/*', limit: '50mb' });
|
|
88
|
+
case 'multipart': return this.multer({ storage: this.multer.memoryStorage() }).array('bundle');
|
|
86
89
|
case '*': return this.express.raw({ type: () => true, limit: '50mb' });
|
|
87
90
|
default: return this.express.json();
|
|
88
91
|
}})();
|
|
@@ -132,26 +135,4 @@ export default class BusinessServer extends Business
|
|
|
132
135
|
try { this.onEnd?.(request, response); } catch(e) { }
|
|
133
136
|
}
|
|
134
137
|
}}
|
|
135
|
-
|
|
136
|
-
public async load(parent: string, path: string): Promise<void>
|
|
137
|
-
{
|
|
138
|
-
/*
|
|
139
|
-
const { readdir } = await import('fs/promises');
|
|
140
|
-
const pathModule = await import('path');
|
|
141
|
-
const { fileURLToPath } = await import('url');
|
|
142
|
-
|
|
143
|
-
// @ts-ignore
|
|
144
|
-
const __dirname = pathModule.dirname(fileURLToPath(parent));
|
|
145
|
-
const servicesPath = pathModule.join(__dirname, path);
|
|
146
|
-
|
|
147
|
-
const files = await readdir(servicesPath);
|
|
148
|
-
for (const file of files) {
|
|
149
|
-
if (!file.endsWith('.ts') && !file.endsWith('.js')) continue;
|
|
150
|
-
const modulePath = pathModule.join(servicesPath, file);
|
|
151
|
-
const mod = await import(modulePath);
|
|
152
|
-
const ServiceClass = Object.values(mod)[0];
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
const instance = new ServiceClass();
|
|
155
|
-
}*/
|
|
156
|
-
}
|
|
157
138
|
}
|