@runnerpro/backend 1.6.14 → 1.6.16
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.
|
@@ -39,7 +39,7 @@ const conversationRoute = (_a) => {
|
|
|
39
39
|
const uploadFile = (0, multer_1.default)({
|
|
40
40
|
dest: 'uploads/',
|
|
41
41
|
limits: {
|
|
42
|
-
fileSize:
|
|
42
|
+
fileSize: 50 * 1024 * 1024,
|
|
43
43
|
files: 1,
|
|
44
44
|
},
|
|
45
45
|
});
|
|
@@ -217,8 +217,6 @@ const getPreferredLanguageForChat = ({ text, idCliente, isClient, query }) => __
|
|
|
217
217
|
});
|
|
218
218
|
const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClient, bucket }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
219
219
|
const { idCliente, type, duration } = req.body;
|
|
220
|
-
console.log('body', req.body);
|
|
221
|
-
console.log('file', req.file);
|
|
222
220
|
const { userid } = req.session;
|
|
223
221
|
const [{ id: idFile }] = yield query('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [MIMETYPE], [DURATION], [TYPE]) VALUES (?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, req.file.originalname, req.file.mimetype, duration || null, type || 2]);
|
|
224
222
|
const filePath = path_1.default.join('./uploads', req.file.filename);
|
|
@@ -238,11 +236,10 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
|
|
|
238
236
|
else {
|
|
239
237
|
files.push({ data: fileData, id: idFile });
|
|
240
238
|
}
|
|
241
|
-
console.log('files', files);
|
|
242
239
|
for (const file of files) {
|
|
243
240
|
yield bucket.file(`Chat/${file.id}`).save(file.data);
|
|
244
241
|
}
|
|
245
|
-
|
|
242
|
+
fs_1.default.unlinkSync(filePath);
|
|
246
243
|
if (!isClient) {
|
|
247
244
|
const [cliente] = yield query('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
|
|
248
245
|
sendNotification({
|
|
@@ -252,7 +249,6 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
|
|
|
252
249
|
url: '/chat',
|
|
253
250
|
});
|
|
254
251
|
}
|
|
255
|
-
console.log('idFile', idFile);
|
|
256
252
|
res.send({ idFile });
|
|
257
253
|
});
|
|
258
254
|
const readMessage = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -293,7 +289,7 @@ const orientationImage = (data, filePath, image = null, mimetype) => __awaiter(v
|
|
|
293
289
|
else if (orientation === 3)
|
|
294
290
|
rotate = 180;
|
|
295
291
|
if (rotate) {
|
|
296
|
-
image = yield image.rotate(
|
|
292
|
+
image = yield image.rotate(rotate);
|
|
297
293
|
}
|
|
298
294
|
return image.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
299
295
|
});
|
package/lib/cjs/db/index.js
CHANGED
|
@@ -26,24 +26,30 @@ exports.pool = pool;
|
|
|
26
26
|
const query = (queryText, values = []) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
27
|
const client = yield pool.connect();
|
|
28
28
|
const text = getParseQuery(queryText, values);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
rowMode: 'json',
|
|
32
|
-
text,
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
values: values.flat(),
|
|
35
|
-
});
|
|
36
|
-
client.release();
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
return (result.rows || []).map((row) => {
|
|
39
|
-
const json = Object.keys(row);
|
|
40
|
-
const aux = {};
|
|
41
|
-
json.forEach((key) => {
|
|
29
|
+
try {
|
|
30
|
+
const result = yield client.query({
|
|
42
31
|
// @ts-ignore
|
|
43
|
-
|
|
32
|
+
rowMode: 'json',
|
|
33
|
+
text,
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
values: values.flat(),
|
|
44
36
|
});
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
client.release();
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
return (result.rows || []).map((row) => {
|
|
40
|
+
const json = Object.keys(row);
|
|
41
|
+
const aux = {};
|
|
42
|
+
json.forEach((key) => {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
aux[camelize(key)] = row[key];
|
|
45
|
+
});
|
|
46
|
+
return aux;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
client.release();
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
47
53
|
});
|
|
48
54
|
exports.query = query;
|
|
49
55
|
const toPgArray = (arr) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAkBpD,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAkBpD,CAAC;AA0SF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,IAAI,CAAC;AAI5B,QAAA,MAAM,IAAI,iBAMR,CAAC;AAEH,QAAA,MAAM,KAAK,cAAqB,MAAM,WAAU,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,IAAI,CAAC;AAI5B,QAAA,MAAM,IAAI,iBAMR,CAAC;AAEH,QAAA,MAAM,KAAK,cAAqB,MAAM,WAAU,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,iBA4B5E,CAAC;AAEF,QAAA,MAAM,SAAS,QAAS,MAAM,EAAE,WAM/B,CAAC;AA+BF,QAAA,MAAM,UAAU,YAAmB,GAAG,mCAUrC,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED