ismx-nexo-node-app 0.4.36 → 0.4.38
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/dist/js/api/ServiceRest.js +2 -2
- package/dist/js/api/ServiceRestFormal.js +2 -2
- package/dist/js/business/BusinessServer.js +1 -0
- package/dist/types/api/Service.d.ts +1 -1
- package/dist/types/api/ServiceRest.d.ts +2 -2
- package/dist/types/api/ServiceRestFormal.d.ts +2 -2
- package/package.json +1 -1
- package/src/main/node/api/Service.ts +1 -1
- package/src/main/node/api/ServiceRest.ts +3 -3
- package/src/main/node/api/ServiceRestFormal.ts +3 -3
- package/src/main/node/business/BusinessServer.ts +1 -0
|
@@ -34,8 +34,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
const Service_1 = __importStar(require("./Service"));
|
|
36
36
|
class ServiceRest extends Service_1.default {
|
|
37
|
-
constructor(method, endpoint = "/") {
|
|
38
|
-
super(method, endpoint);
|
|
37
|
+
constructor(method, endpoint = "/", type = "json") {
|
|
38
|
+
super(method, endpoint, type);
|
|
39
39
|
}
|
|
40
40
|
serve(request) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -39,8 +39,8 @@ const Service_1 = __importStar(require("./Service"));
|
|
|
39
39
|
const ServiceRest_1 = __importDefault(require("./ServiceRest"));
|
|
40
40
|
const BusinessErrors_1 = require("../business/BusinessErrors");
|
|
41
41
|
class ServiceRestFormal extends ServiceRest_1.default {
|
|
42
|
-
constructor(method, endpoint = "/") {
|
|
43
|
-
super(method, endpoint);
|
|
42
|
+
constructor(method, endpoint = "/", type = "json") {
|
|
43
|
+
super(method, endpoint, type);
|
|
44
44
|
}
|
|
45
45
|
serveRest(request) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -82,6 +82,7 @@ class BusinessServer extends Business_1.default {
|
|
|
82
82
|
case 'json': return this.express.json();
|
|
83
83
|
case 'xml': return this.express.xml();
|
|
84
84
|
case 'stream': return this.express.raw({ type: 'application/octet-stream', limit: '10mb' });
|
|
85
|
+
case 'image': return this.express.raw({ type: 'image/*', limit: '10mb' });
|
|
85
86
|
default: return this.express.json();
|
|
86
87
|
}
|
|
87
88
|
})();
|
|
@@ -24,7 +24,7 @@ export declare class HttpResponse<T = any> {
|
|
|
24
24
|
static ok<T = any>(content: T): HttpResponse<any>;
|
|
25
25
|
static ko<T = any>(httpCode: number, content: T): HttpResponse<any>;
|
|
26
26
|
}
|
|
27
|
-
export type ServiceType = "json" | "xml" | 'stream';
|
|
27
|
+
export type ServiceType = "json" | "xml" | 'stream' | 'image';
|
|
28
28
|
export default abstract class Service<Req, Res> {
|
|
29
29
|
static readonly services: Service<any, any>[];
|
|
30
30
|
readonly method: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Service, { HttpRequest, HttpResponse } from "./Service";
|
|
1
|
+
import Service, { HttpRequest, HttpResponse, ServiceType } from "./Service";
|
|
2
2
|
export default class ServiceRest<Req, Res> extends Service<Req, Res> {
|
|
3
|
-
constructor(method: string, endpoint?: string);
|
|
3
|
+
constructor(method: string, endpoint?: string, type?: ServiceType);
|
|
4
4
|
serve(request: HttpRequest<Req>): Promise<HttpResponse<Res>>;
|
|
5
5
|
serveRest(request: HttpRequest<Req>): Promise<HttpResponse<Res>>;
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpRequest, HttpResponse } from "./Service";
|
|
1
|
+
import { HttpRequest, HttpResponse, ServiceType } from "./Service";
|
|
2
2
|
import ServiceRest from "./ServiceRest";
|
|
3
3
|
export interface Wrapper<T> {
|
|
4
4
|
code: string;
|
|
@@ -7,7 +7,7 @@ export interface Wrapper<T> {
|
|
|
7
7
|
debug?: string;
|
|
8
8
|
}
|
|
9
9
|
export default class ServiceRestFormal<Req = any, Res = any> extends ServiceRest<Req, Wrapper<Res>> {
|
|
10
|
-
constructor(method: string, endpoint?: string);
|
|
10
|
+
constructor(method: string, endpoint?: string, type?: ServiceType);
|
|
11
11
|
serveRest(request: HttpRequest<Req>): Promise<HttpResponse<Wrapper<Res>>>;
|
|
12
12
|
serveRestFormal(request: HttpRequest<Req>): Promise<HttpResponse<Res>>;
|
|
13
13
|
unwrap<Res>(request: Promise<HttpResponse<Wrapper<Res>>>): Promise<Res | undefined>;
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export class HttpResponse<T = any> {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export type ServiceType = "json" | "xml" | 'stream';
|
|
32
|
+
export type ServiceType = "json" | "xml" | 'stream' | 'image';
|
|
33
33
|
export default abstract class Service<Req, Res>
|
|
34
34
|
{
|
|
35
35
|
public static readonly services: Service<any, any>[] = []
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Service, {HttpRequest, HttpResponse} from "./Service";
|
|
1
|
+
import Service, {HttpRequest, HttpResponse, ServiceType} from "./Service";
|
|
2
2
|
|
|
3
3
|
export default class ServiceRest<Req, Res> extends Service<Req, Res>
|
|
4
4
|
{
|
|
5
|
-
constructor(method: string, endpoint: string = "/") {
|
|
6
|
-
super(method, endpoint);
|
|
5
|
+
constructor(method: string, endpoint: string = "/", type: ServiceType = "json") {
|
|
6
|
+
super(method, endpoint, type);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async serve(request: HttpRequest<Req>): Promise<HttpResponse<Res>>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Service, {HttpRequest, HttpResponse} from "./Service";
|
|
1
|
+
import Service, {HttpRequest, HttpResponse, ServiceType} from "./Service";
|
|
2
2
|
import ServiceRest from "./ServiceRest";
|
|
3
3
|
import {FormalError} from "../business/BusinessErrors";
|
|
4
4
|
|
|
@@ -11,8 +11,8 @@ export interface Wrapper<T> {
|
|
|
11
11
|
|
|
12
12
|
export default class ServiceRestFormal<Req=any, Res=any> extends ServiceRest<Req, Wrapper<Res>>
|
|
13
13
|
{
|
|
14
|
-
constructor(method: string, endpoint: string = "/") {
|
|
15
|
-
super(method, endpoint);
|
|
14
|
+
constructor(method: string, endpoint: string = "/", type: ServiceType = "json") {
|
|
15
|
+
super(method, endpoint, type);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async serveRest(request: HttpRequest<Req>): Promise<HttpResponse<Wrapper<Res>>>
|
|
@@ -64,6 +64,7 @@ export default class BusinessServer extends Business
|
|
|
64
64
|
case 'json': return this.express.json();
|
|
65
65
|
case 'xml': return this.express.xml();
|
|
66
66
|
case 'stream': return this.express.raw({ type: 'application/octet-stream', limit: '10mb' });
|
|
67
|
+
case 'image': return this.express.raw({ type: 'image/*', limit: '10mb' });
|
|
67
68
|
default: return this.express.json();
|
|
68
69
|
}})();
|
|
69
70
|
|