ismx-nexo-node-app 0.4.63 → 0.4.65

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.
@@ -126,15 +126,17 @@ class ServiceRestFormalTemplate {
126
126
  serveMap(request) {
127
127
  return __awaiter(this, void 0, void 0, function* () {
128
128
  let results = yield this.database.find(this.tableName, Object.assign({}, request.query));
129
+ let extended = results.map((entity) => this.extendEntity(entity));
129
130
  let response = {};
130
- for (let result of results) {
131
- let key = result[this.indexer];
132
- if (!key)
133
- return Service_1.HttpResponse.ok({});
134
- else
135
- response[key] = this.extendEntity(result);
136
- }
137
- yield Promise.all(Object.values(response));
131
+ yield Promise.all(extended).then((entities) => {
132
+ for (let entity of entities) {
133
+ let key = entity[this.indexer];
134
+ if (!key)
135
+ return Service_1.HttpResponse.ok({});
136
+ else
137
+ response[key] = entity;
138
+ }
139
+ });
138
140
  return Service_1.HttpResponse.ok(response);
139
141
  });
140
142
  }
@@ -38,7 +38,7 @@ class RepositoryRest extends Repository_1.default {
38
38
  headers.set(header, (_e = (_d = request.headers) === null || _d === void 0 ? void 0 : _d[header]) !== null && _e !== void 0 ? _e : "");
39
39
  // Si el body especificado es un objeto, lo convierte a JSON.
40
40
  let body = request.body;
41
- if (request.body && typeof request.body !== 'string' && !Buffer.isBuffer(request.body)) {
41
+ if (request.body && typeof request.body !== 'string' && typeof Buffer !== 'undefined' && !Buffer.isBuffer(request.body)) {
42
42
  headers.set('Content-Type', 'application/json');
43
43
  body = JSON.stringify(request.body);
44
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.63",
3
+ "version": "0.4.65",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -134,13 +134,16 @@ export default class ServiceRestFormalTemplate<Model=any>
134
134
  */
135
135
  protected async serveMap(request: HttpRequest): Promise<HttpResponse<{[key: string]: Model}>> {
136
136
  let results = await this.database.find<Model>(this.tableName, { ...request.query });
137
- let response: {[key: string]: Promise<Model>} = {};
138
- for (let result of results) {
139
- let key = (result as any)[this.indexer];
140
- if (!key) return HttpResponse.ok({});
141
- else response[key] = this.extendEntity(result);
142
- }
143
- await Promise.all(Object.values(response));
137
+ let extended = results.map((entity) => this.extendEntity(entity));
138
+
139
+ let response: {[key: string]: Model} = {};
140
+ await Promise.all(extended).then((entities) => {
141
+ for (let entity of entities) {
142
+ let key = (entity as any)[this.indexer];
143
+ if (!key) return HttpResponse.ok({});
144
+ else response[key] = entity;
145
+ }
146
+ });
144
147
  return HttpResponse.ok(response);
145
148
  }
146
149
 
@@ -47,7 +47,7 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
47
47
 
48
48
  // Si el body especificado es un objeto, lo convierte a JSON.
49
49
  let body: string | undefined = request.body as string;
50
- if (request.body && typeof request.body !== 'string' && !Buffer.isBuffer(request.body)) {
50
+ if (request.body && typeof request.body !== 'string' && typeof Buffer !== 'undefined' && !Buffer.isBuffer(request.body)) {
51
51
  headers.set('Content-Type', 'application/json');
52
52
  body = JSON.stringify(request.body);
53
53
  }