Skip to content

Commit

Permalink
perf(backend): Improve save files from editor
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed May 12, 2024
1 parent 03ab442 commit b55a89f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"config:database": "ts-node ./src/utils/actions/finish-build.ts",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"dev": "cross-env NODE_ENV=development pnpm config:database && nest start -b swc -w",
"dev": "pnpm config:database && cross-env NODE_ENV=development nest start -b swc -w",
"start": "nest start -b swc",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
Expand Down
10 changes: 3 additions & 7 deletions backend/src/database/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ import * as dotenv from "dotenv";

import { schemaDatabase } from "./schema";

if (
!(process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test")
) {
dotenv.config({
path: join(process.cwd(), "..", ".env")
});
}
dotenv.config({
path: join(process.cwd(), "..", ".env")
});

export const DATABASE_ENVS = {
host: process.env.DB_HOST ?? "localhost",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "@nestjs/common";
import { Response } from "express";
import { DatabaseService } from "@/database/database.service";
import { ABSOLUTE_PATHS } from "@/config";

@Controller("secure_files")
export class DownloadSecureFilesController {
Expand All @@ -32,7 +33,11 @@ export class DownloadSecureFilesController {
return;
}

const path = join(process.cwd(), file.dir_folder, file.file_name);
const path = join(
ABSOLUTE_PATHS.uploads.private,
file.dir_folder,
file.file_name
);

const mediaType = file.mimetype.split("/")[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export class UploadCoreFilesService extends HelpersUploadCoreFilesService {
folder
);
const dirFolder = secure
? join(process.cwd(), dir) // Save files in the backend folder
: join(ABSOLUTE_PATHS.uploads.public, dir); // Save files in the public folder
? join(ABSOLUTE_PATHS.uploads.private, dir)
: join(ABSOLUTE_PATHS.uploads.public, dir);
if (!existsSync(dirFolder)) {
mkdirSync(dirFolder, { recursive: true });
}
Expand Down
6 changes: 3 additions & 3 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ version: "3.8"
services:
postgres:
container_name: vitnode_postgres_dev
image: postgres:16.2-alpine
restart: on-failure
image: postgres:16.3-alpine
restart: unless-stopped
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
Expand All @@ -20,7 +20,7 @@ services:
pgadmin:
container_name: vitnode_pgadmin_dev
image: dpage/pgadmin4:latest
restart: on-failure
restart: unless-stopped
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: admin
Expand Down

0 comments on commit b55a89f

Please sign in to comment.