Compare commits
No commits in common. "30026df2d04cf47017dec78230ef6313a5b694f9" and "ef8ba655f3866bcc211beae23e8fc8068a9b0794" have entirely different histories.
30026df2d0
...
ef8ba655f3
@ -3,10 +3,9 @@ import { DbModule } from "../db/db.module";
|
||||
import { StorageModule } from "../storage/storage.module";
|
||||
import { FilesController } from "./files.controller";
|
||||
import { FilesService } from "./files.service";
|
||||
import { CredentialsModule } from '../credentials/credentials.module';
|
||||
|
||||
@Module({
|
||||
imports: [StorageModule, DbModule, CredentialsModule],
|
||||
imports: [StorageModule, DbModule],
|
||||
controllers: [FilesController],
|
||||
providers: [FilesService],
|
||||
})
|
||||
|
@ -62,7 +62,7 @@ export class FilesService {
|
||||
);
|
||||
const fileNameWithoutSpaces = file.fileName.replace(/\s/g, "_");
|
||||
return new StreamableFile(fileBuffer, {
|
||||
disposition: `attachment; filename="${fileNameWithoutSpaces}.${fileInformation.fileType[0].extension.toLowerCase()}"`,
|
||||
disposition: `attachment; filename="${fileNameWithoutSpaces}.${fileInformation.fileType.ext.toLowerCase()}"`,
|
||||
});
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ export class FilesService {
|
||||
.values({
|
||||
fileName: data.get("fileName") as string,
|
||||
checksum: saveResult.fileChecksum,
|
||||
extension: saveResult.fileType[0].extension,
|
||||
extension: saveResult.fileType.ext,
|
||||
fileSize: saveResult.fileSize,
|
||||
fileType: saveResult.fileType.mime,
|
||||
isRestricted: Boolean(data.get("isRestricted")),
|
||||
|
@ -1,10 +1,8 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { MachinesController } from "apps/backend/src/app/machines/machines.controller";
|
||||
import { MachinesService } from "apps/backend/src/app/machines/machines.service";
|
||||
import { DbModule } from 'apps/backend/src/app/db/db.module';
|
||||
|
||||
@Module({
|
||||
imports: [DbModule],
|
||||
controllers: [MachinesController],
|
||||
providers: [MachinesService],
|
||||
})
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { DbModule } from "../db/db.module";
|
||||
import { StorageService } from "../storage/storage.service";
|
||||
import { DbModule } from "apps/backend/src/app/db/db.module";
|
||||
import { StorageService } from "apps/backend/src/app/storage/storage.service";
|
||||
|
||||
@Module({
|
||||
imports: [DbModule],
|
||||
providers: [StorageService],
|
||||
exports: [StorageService]
|
||||
})
|
||||
export class StorageModule {}
|
||||
|
@ -16,7 +16,7 @@ import {
|
||||
} from "apps/backend/src/app/db/schema";
|
||||
import { IFileInformation } from "apps/backend/src/app/storage/storage.types";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { filetypeinfo } from 'magic-bytes.js';
|
||||
import FileType from "file-type";
|
||||
|
||||
@Injectable()
|
||||
export class StorageService {
|
||||
@ -61,7 +61,7 @@ export class StorageService {
|
||||
return allowedMime.has(currentMime);
|
||||
}
|
||||
|
||||
const fileType = filetypeinfo(file);
|
||||
const fileType = await FileType.fileTypeFromBuffer(file);
|
||||
|
||||
// Array of MIMEs with possible duplicate field
|
||||
const _mimes: Array<string> = [];
|
||||
@ -106,7 +106,7 @@ export class StorageService {
|
||||
});
|
||||
}
|
||||
|
||||
if (!checkMime(mimeSet, fileType[0].mime))
|
||||
if (!checkMime(mimeSet, fileType.mime))
|
||||
throw new BadRequestException({
|
||||
cause: "MIME type",
|
||||
description: `Invalid MIME type. Allowed MIME types are: ${[...mimeSet].join(", ")}.`,
|
||||
@ -164,15 +164,15 @@ export class StorageService {
|
||||
fileDisplayName: string,
|
||||
isDocumentation?: boolean,
|
||||
): Promise<IFileInformation> {
|
||||
const fileType = filetypeinfo(file);
|
||||
const fileType = await FileType.fileTypeFromBuffer(file);
|
||||
const checksum = await this.getChecksum(file);
|
||||
const fileName = `${isDocumentation ? "doc" : "file"}-${checksum}.${fileType[0].extension.toLowerCase()}`;
|
||||
const fileName = `${isDocumentation ? "doc" : "file"}-${checksum}.${fileType.ext.toLowerCase()}`;
|
||||
return {
|
||||
fileName: fileName,
|
||||
fileDisplayName: fileDisplayName,
|
||||
fileSize: file.byteLength,
|
||||
fileChecksum: checksum,
|
||||
fileType: fileType[0],
|
||||
fileType: fileType,
|
||||
isDocumentation: isDocumentation || false,
|
||||
};
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { StreamableFile } from "@nestjs/common";
|
||||
import { GuessedFile } from 'magic-bytes.js/dist/model/tree';
|
||||
import FileType from "file-type";
|
||||
|
||||
export interface IFileInformation {
|
||||
fileDisplayName: string;
|
||||
fileName: string;
|
||||
fileChecksum: string;
|
||||
isDocumentation: boolean;
|
||||
fileType: GuessedFile;
|
||||
fileType: FileType.FileTypeResult;
|
||||
fileSize: number;
|
||||
}
|
||||
|
||||
|
64
package.json
64
package.json
@ -3,10 +3,7 @@
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"check": "biome check --skip-errors --apply apps",
|
||||
"db:generate": "drizzle-kit generate",
|
||||
"db:migrate": "drizzle-kit migrate",
|
||||
"db:studio": "drizzle-kit studio"
|
||||
"check": "biome check --skip-errors --apply apps"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
@ -17,32 +14,32 @@
|
||||
"@nestjs/mapped-types": "*",
|
||||
"@nestjs/platform-express": "^10.4.4",
|
||||
"@nestjs/throttler": "^6.2.1",
|
||||
"@radix-ui/react-accordion": "^1.2.1",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.2",
|
||||
"@radix-ui/react-accordion": "^1.2.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
||||
"@radix-ui/react-avatar": "^1.1.1",
|
||||
"@radix-ui/react-checkbox": "^1.1.2",
|
||||
"@radix-ui/react-collapsible": "^1.1.1",
|
||||
"@radix-ui/react-context-menu": "^2.2.2",
|
||||
"@radix-ui/react-dialog": "^1.1.2",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
||||
"@radix-ui/react-hover-card": "^1.1.2",
|
||||
"@radix-ui/react-avatar": "^1.1.0",
|
||||
"@radix-ui/react-checkbox": "^1.1.1",
|
||||
"@radix-ui/react-collapsible": "^1.1.0",
|
||||
"@radix-ui/react-context-menu": "^2.2.1",
|
||||
"@radix-ui/react-dialog": "^1.1.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
||||
"@radix-ui/react-hover-card": "^1.1.1",
|
||||
"@radix-ui/react-label": "^2.1.0",
|
||||
"@radix-ui/react-menubar": "^1.1.2",
|
||||
"@radix-ui/react-navigation-menu": "^1.2.1",
|
||||
"@radix-ui/react-popover": "^1.1.2",
|
||||
"@radix-ui/react-menubar": "^1.1.1",
|
||||
"@radix-ui/react-navigation-menu": "^1.2.0",
|
||||
"@radix-ui/react-popover": "^1.1.1",
|
||||
"@radix-ui/react-progress": "^1.1.0",
|
||||
"@radix-ui/react-radio-group": "^1.2.1",
|
||||
"@radix-ui/react-scroll-area": "^1.2.0",
|
||||
"@radix-ui/react-radio-group": "^1.2.0",
|
||||
"@radix-ui/react-scroll-area": "^1.1.0",
|
||||
"@radix-ui/react-separator": "^1.1.0",
|
||||
"@radix-ui/react-slider": "^1.2.1",
|
||||
"@radix-ui/react-slider": "^1.2.0",
|
||||
"@radix-ui/react-slot": "^1.1.0",
|
||||
"@radix-ui/react-switch": "^1.1.1",
|
||||
"@radix-ui/react-tabs": "^1.1.1",
|
||||
"@radix-ui/react-toast": "^1.2.2",
|
||||
"@radix-ui/react-switch": "^1.1.0",
|
||||
"@radix-ui/react-tabs": "^1.1.0",
|
||||
"@radix-ui/react-toast": "^1.2.1",
|
||||
"@radix-ui/react-toggle": "^1.1.0",
|
||||
"@radix-ui/react-toggle-group": "^1.1.0",
|
||||
"@radix-ui/react-tooltip": "^1.1.3",
|
||||
"@radix-ui/react-tooltip": "^1.1.2",
|
||||
"argon2": "^0.41.1",
|
||||
"axios": "^1.7.7",
|
||||
"class-transformer": "^0.5.1",
|
||||
@ -56,29 +53,28 @@
|
||||
"embla-carousel-react": "^8.3.0",
|
||||
"express": "^4.21.0",
|
||||
"file-type": "^19.5.0",
|
||||
"helmet": "^7.2.0",
|
||||
"helmet": "^7.1.0",
|
||||
"input-otp": "^1.2.4",
|
||||
"jose": "^5.9.3",
|
||||
"lucide-react": "^0.429.0",
|
||||
"magic-bytes.js": "^1.10.0",
|
||||
"next": "14.2.3",
|
||||
"next-themes": "^0.3.0",
|
||||
"postgres": "^3.4.4",
|
||||
"react": "18.3.1",
|
||||
"react-day-picker": "^9.1.3",
|
||||
"react-day-picker": "^9.1.2",
|
||||
"react-dom": "18.3.1",
|
||||
"react-resizable-panels": "^2.1.4",
|
||||
"react-resizable-panels": "^2.1.3",
|
||||
"recharts": "^2.12.7",
|
||||
"reflect-metadata": "^0.1.14",
|
||||
"rxjs": "^7.8.1",
|
||||
"sonner": "^1.5.0",
|
||||
"tailwind-merge": "^2.5.3",
|
||||
"tailwind-merge": "^2.5.2",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"ts-mockito": "^2.6.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.9.3",
|
||||
"@biomejs/biome": "^1.9.2",
|
||||
"@nestjs/schematics": "^10.1.4",
|
||||
"@nestjs/testing": "^10.4.4",
|
||||
"@nx/cypress": "19.6.1",
|
||||
@ -86,16 +82,16 @@
|
||||
"@nx/eslint-plugin": "19.6.1",
|
||||
"@nx/jest": "19.6.1",
|
||||
"@nx/js": "19.6.1",
|
||||
"@nx/nest": "^19.8.4",
|
||||
"@nx/nest": "^19.8.0",
|
||||
"@nx/next": "19.6.1",
|
||||
"@nx/node": "19.6.1",
|
||||
"@nx/react": "19.6.1",
|
||||
"@nx/web": "19.6.1",
|
||||
"@nx/webpack": "19.6.1",
|
||||
"@nx/workspace": "19.6.1",
|
||||
"@swc-node/register": "~1.10.9",
|
||||
"@swc-node/register": "~1.9.2",
|
||||
"@swc/cli": "~0.3.14",
|
||||
"@swc/core": "~1.7.26",
|
||||
"@swc/core": "~1.5.29",
|
||||
"@swc/helpers": "~0.5.13",
|
||||
"@types/jest": "^29.5.13",
|
||||
"@types/node": "18.16.9",
|
||||
@ -105,7 +101,7 @@
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"autoprefixer": "10.4.13",
|
||||
"babel-jest": "^29.7.0",
|
||||
"cypress": "^13.15.0",
|
||||
"cypress": "^13.14.2",
|
||||
"eslint": "~8.57.1",
|
||||
"eslint-config-next": "14.2.3",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
@ -122,7 +118,7 @@
|
||||
"tailwindcss": "3.4.3",
|
||||
"ts-jest": "^29.2.5",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "~5.6.2",
|
||||
"typescript": "~5.5.4",
|
||||
"webpack-cli": "^5.1.4"
|
||||
}
|
||||
}
|
||||
|
1672
pnpm-lock.yaml
generated
1672
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user