Skip to content

Commit

Permalink
feat: disable sharp package
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-d committed Jan 3, 2024
1 parent 94818f3 commit 650bb99
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
20 changes: 10 additions & 10 deletions .deploy/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"devDependencies": {
"@nestjs/schematics": "^10.0.1",
"@nestjs/testing": "^10.0.2",
"@nx/jest": "16.6.0",
"@nx/js": "16.6.0",
"@nx/nest": "16.6.0",
"@nx/node": "16.6.0",
"@nx/rollup": "16.6.0",
"@nx/web": "16.6.0",
"@nx/webpack": "16.6.0",
"@nx/workspace": "16.6.0",
"@nx/jest": "17.1.2",
"@nx/js": "17.1.2",
"@nx/nest": "17.1.2",
"@nx/node": "17.1.2",
"@nx/rollup": "17.1.2",
"@nx/web": "17.1.2",
"@nx/webpack": "17.1.2",
"@nx/workspace": "17.1.2",
"@swc/cli": "~0.1.62",
"@swc/core": "~1.3.51",
"@swc/jest": "0.2.20",
Expand All @@ -41,10 +41,10 @@
"eslint": "8.15.0",
"eslint-config-prettier": "8.1.0",
"jest": "29.4.3",
"nx": "16.6.0",
"nx": "17.1.2",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typescript": "5.1.3"
"typescript": "5.2.2"
},
"workspaces": [
"apps/*",
Expand Down
3 changes: 1 addition & 2 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/analytics",
"version": "0.0.1",
"version": "1.18.0",
"type": "commonjs",
"license": "MIT",
"scripts": {
Expand Down Expand Up @@ -28,7 +28,6 @@
"nestjs-i18n": "^8.1.6",
"redis": "^4.0.4",
"reflect-metadata": "^0.1.13",
"sharp": "^0.30.5",
"socket.io-redis": "6.1.1",
"typeorm": "^0.2.37",
"xml2js": "^0.4.23"
Expand Down
27 changes: 14 additions & 13 deletions packages/analytics/src/screenshot/screenshot.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import * as path from 'path';
import * as moment from 'moment';
import * as sharp from 'sharp';
// import * as sharp from 'sharp'; It's a bug in install sharp in docker image
import * as fs from 'fs';
import { FileStorageProviderEnum, IScreenshot, UploadedFile } from '@metad/contracts';
import { Screenshot } from './screenshot.entity';
Expand Down Expand Up @@ -68,20 +68,21 @@ export class ScreenshotController extends CrudController<Screenshot> {
const inputFile = await tempFile('screenshot-thumb');
const outputFile = await tempFile('screenshot-thumb');
await fs.promises.writeFile(inputFile, fileContent);
await new Promise((resolve, reject) => {
sharp(inputFile)
.resize(250, 150)
.toFile(outputFile, (error: any, data: any) => {
if (error) {
reject(error);
} else {
resolve(data);
}
});
});
// await new Promise((resolve, reject) => {
// sharp(inputFile)
// .resize(250, 150)
// .toFile(outputFile, (error: any, data: any) => {
// if (error) {
// reject(error);
// } else {
// resolve(data);
// }
// });
// });
const thumbName = `thumb-${file.filename}`;
const thumbDir = path.dirname(file.key);
const data = await fs.promises.readFile(outputFile);
// const data = await fs.promises.readFile(outputFile);
const data = await fs.promises.readFile(inputFile);
await fs.promises.unlink(inputFile);
await fs.promises.unlink(outputFile);

Expand Down

0 comments on commit 650bb99

Please sign in to comment.