Refactor logistics and frontend code for better consistency.

Refactored several files to improve code clarity, error handling, and data integrity. Introduced type safety improvements, streamlined OpenAPI model integration, adjusted configuration settings, and enhanced QR code handling logic. Also updated scripts and tsconfig settings to temporarily bypass strict checks during development.
This commit is contained in:
GotthardG
2025-03-06 13:24:12 +01:00
parent 9c73e1df4c
commit 3d55c42312
9 changed files with 196 additions and 56 deletions

View File

@ -130,6 +130,32 @@ async function fetchAndGenerate() {
} else {
console.log(`✅ Service generation completed successfully:\n${stdout}`);
}
// Copy the generated OpenAPI models to ../logistics/openapi
const targetDirectory = path.resolve('../logistics/openapi'); // Adjust as per logistics directory
console.log(`🔄 Copying generated OpenAPI models to ${targetDirectory}...`);
await fs.promises.rm(targetDirectory, { recursive: true, force: true }); // Clean target directory
await fs.promises.mkdir(targetDirectory, { recursive: true }); // Ensure the directory exists
// Copy files from OUTPUT_DIRECTORY to the target directory recursively
const copyRecursive = async (src, dest) => {
const entries = await fs.promises.readdir(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
await fs.promises.mkdir(destPath, { recursive: true });
await copyRecursive(srcPath, destPath);
} else {
await fs.promises.copyFile(srcPath, destPath);
}
}
};
await copyRecursive(OUTPUT_DIRECTORY, targetDirectory);
console.log(`✅ OpenAPI models copied successfully to ${targetDirectory}`);
} catch (error) {
console.error(`❌ Error during schema processing or generation: ${error.message}`);
}
@ -141,7 +167,6 @@ async function fetchAndGenerate() {
}
}
// Backend directory based on the environment
// Backend directory based on the environment
const backendDirectory = (() => {
switch (nodeEnv) {