📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Added error handler
Yevheniia0ae0d7f9242
diff --git a/src/marketplace/cdn/cdn.service.ts b/src/marketplace/cdn/cdn.service.tsindex f553c6d4b..fcc0eeb7d 100644--- a/src/marketplace/cdn/cdn.service.ts+++ b/src/marketplace/cdn/cdn.service.ts@@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common'import { ConfigService } from '@nestjs/config'import { createReadStream } from 'fs'import { unlink, writeFile } from 'fs/promises'-import { join } from 'path'+import { tmpdir } from 'os'import * as FormData from 'form-data'@Injectable()@@ -14,30 +14,36 @@ export class CdnService {) {}async uploadFile(file: Express.Multer.File): Promise<{ filename: string }> {- const filePath = `${join(__dirname, '..', '..', '..', 'tmp')}/${- file.originalname- }`+ try {+ const filePath = `${tmpdir()}/${file.originalname}`- await writeFile(filePath, file.buffer)+ await writeFile(filePath, file.buffer)- const form = new FormData()- form.append('token', this.configService.get('CDN_ACCESS_TOKEN'))- form.append('file', createReadStream(filePath))+ const form = new FormData()+ form.append('token', this.configService.get('CDN_ACCESS_TOKEN'))+ form.append('file', createReadStream(filePath))- const { data } = await this.httpService.axiosRef.post('file', form, {- headers: {- 'Content-Type': 'multipart/form-data',- },- })+ const { data } = await this.httpService.axiosRef.post('file', form, {+ headers: {+ 'Content-Type': 'multipart/form-data',+ },+ })- await unlink(filePath)+ await unlink(filePath)- return data+ return data+ } catch (error) {+ console.error(error)+ }}async deleteFile(filename: string): Promise<void> {- await this.httpService.axiosRef.delete(`file/${filename}`, {- data: { token: this.configService.get('CDN_ACCESS_TOKEN') },- })+ try {+ await this.httpService.axiosRef.delete(`file/${filename}`, {+ data: { token: this.configService.get('CDN_ACCESS_TOKEN') },+ })+ } catch (error) {+ console.error(error)+ }}}diff --git a/tmp/.gitkeep b/tmp/.gitkeepdeleted file mode 100644index e69de29bb..000000000