-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(uploads): overhaul file handling and paths across containers
BREAKING CHANGES: - Simplified directory structure for uploads - Remove filesystem operations from frontend consts.ts - Standardize paths across containers - Update API URLs to use container hostnames Features: - Remove redundant directory creation logic - Simplify path resolution in frontend - Add better error handling for file operations - Use container networking DNS resolution Technical Updates: - Change API_BASE_URL to use service name: kenyare-backend:8000 - Remove fs operations from consts.ts - Update path handling in saveFile function - Add detailed error logging - Fix directory permissions
- Loading branch information
1 parent
78af46f
commit 5ed14de
Showing
2 changed files
with
6 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,8 @@ | ||
import "dotenv/config"; | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
|
||
const FLASK_PORT = process.env.FLASK_PORT ?? 8000; | ||
const FLASK_HOST = process.env.FLASK_HOST ?? "http://127.0.0.1"; | ||
export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || "http://kenyare-backend:8000"; | ||
const UPLOADS_DIR = 'uploads'; | ||
export const FINANCIAL_AUDITS_DIR = '/api/static/uploads/audits'; | ||
export const PROPOSAL_FORMS_DIR = '/api/static/uploads/proposals'; | ||
export const QUOTATIONS_DIR = '/api/static/uploads/quotations'; | ||
// Update paths to be relative to container mount point | ||
export const FINANCIAL_AUDITS_DIR = 'audits'; | ||
export const PROPOSAL_FORMS_DIR = 'proposals'; | ||
export const QUOTATIONS_DIR = 'quotations'; | ||
export const DELETE_UPLOADS = process.env.DELETE_UPLOADS === "1"; | ||
|
||
if (!fs.existsSync(UPLOADS_DIR)) await fs.promises.mkdir(UPLOADS_DIR); | ||
if (process.env.CLEAR_UPLOADS_DIR === "1") { | ||
await fs.promises.rm(UPLOADS_DIR, { recursive: true }); | ||
await fs.promises.mkdir(UPLOADS_DIR); | ||
|
||
} | ||
|
||
if (!fs.existsSync(FINANCIAL_AUDITS_DIR)) await fs.promises.mkdir(FINANCIAL_AUDITS_DIR); | ||
if (!fs.existsSync(PROPOSAL_FORMS_DIR)) await fs.promises.mkdir(PROPOSAL_FORMS_DIR); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters