@runnerpro/backend 1.12.7 → 1.12.8

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.
@@ -53,6 +53,7 @@ const conversationRoute = (_a) => {
53
53
  router.delete('/conversation/:id', (req, res, next) => deleteConversationMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
54
54
  router.put('/conversation/:id', (req, res, next) => editConversationMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
55
55
  router.get('/conversation/image/:id', (req, res, next) => getConversationImage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
56
+ router.get('/conversation/thumbnail/:id', (req, res, next) => getConversationThumbnail(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
56
57
  router.get('/conversation/file/:id', (req, res, next) => getConversationFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
57
58
  router.post('/conversation/send', (req, res, next) => sendMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
58
59
  router.post('/conversation/send-file', uploadFile.single('file'), (req, res, next) => sendFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
@@ -166,6 +167,22 @@ const getConversationImage = (req, res, { bucket, isClient }) => __awaiter(void
166
167
  mimetype: result.message.mimetype,
167
168
  });
168
169
  });
170
+ const getConversationThumbnail = (req, res, { bucket, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
171
+ const { id: idVideo } = req.params;
172
+ const [file] = yield bucket.file(`Chat/${idVideo}-thumbnail`).exists();
173
+ if (!file)
174
+ return res.status(404).send('Not found');
175
+ const [thumbnail] = yield bucket.file(`Chat/${idVideo}-thumbnail`).download();
176
+ res.writeHead(200, {
177
+ 'Content-Type': 'image/jpeg',
178
+ 'Content-disposition': 'inline',
179
+ 'Content-Length': file.length,
180
+ });
181
+ res.end({
182
+ file: thumbnail.toString('base64'),
183
+ mimetype: 'image/jpeg',
184
+ });
185
+ });
169
186
  const getConversationFile = (req, res, { bucket, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
170
187
  const result = yield getChatFile({
171
188
  bucket,
@@ -319,11 +336,10 @@ const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, f
319
336
  resolve(buffer);
320
337
  }
321
338
  catch (error) {
322
- console.error('Error leyendo archivo temporal:', error);
323
339
  reject(error);
324
340
  }
325
341
  })
326
- .on('error', (err) => {
342
+ .on('error', (error) => {
327
343
  // Limpiar archivo temporal en caso de error
328
344
  try {
329
345
  if (fs_1.default.existsSync(outputPath)) {
@@ -331,19 +347,18 @@ const getThumbnailFromVideo = (videoPath) => __awaiter(void 0, void 0, void 0, f
331
347
  }
332
348
  }
333
349
  catch (cleanupError) {
350
+ // eslint-disable-next-line no-console
334
351
  console.error('Error limpiando archivo temporal:', cleanupError);
335
352
  }
336
- console.error('Error generando thumbnail:', err);
337
- reject(err);
353
+ reject(error);
338
354
  });
339
355
  });
340
356
  });
341
357
  const getVideoDuration = (videoPath) => __awaiter(void 0, void 0, void 0, function* () {
342
358
  return new Promise((resolve, reject) => {
343
- fluent_ffmpeg_1.default.ffprobe(videoPath, (err, metadata) => {
344
- if (err) {
345
- console.error('Error con ffprobe:', err);
346
- reject(err);
359
+ fluent_ffmpeg_1.default.ffprobe(videoPath, (error, metadata) => {
360
+ if (error) {
361
+ reject(error);
347
362
  return;
348
363
  }
349
364
  try {
@@ -354,9 +369,8 @@ const getVideoDuration = (videoPath) => __awaiter(void 0, void 0, void 0, functi
354
369
  const durationInSeconds = Math.round(parseFloat(duration));
355
370
  resolve(durationInSeconds);
356
371
  }
357
- catch (error) {
358
- console.error('Error procesando metadata:', error);
359
- reject(error);
372
+ catch (errorCatch) {
373
+ reject(errorCatch);
360
374
  }
361
375
  });
362
376
  });
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAoBpD,CAAC;AA6XF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;AA4YF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.12.7",
3
+ "version": "1.12.8",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"