Skip to content

Commit

Permalink
Merge pull request #4 from Agoric/rs-update-upload-dir
Browse files Browse the repository at this point in the history
chore: create upload directory when server starts
  • Loading branch information
rabi-siddique authored Nov 4, 2024
2 parents e62fa28 + b3624f4 commit fab64d7
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -2,15 +2,21 @@ import './lockdown.js';
import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
import { fs } from 'zx';
import router from './router.js';
import { requestLogger } from './middleware/requestLogger.js';

const PORT = 3000;
const UPLOAD_DIR = 'uploads';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const app = express();

if (!fs.existsSync(UPLOAD_DIR)) {
fs.mkdirSync(UPLOAD_DIR);
}

// Serve static files
app.use(express.static(path.join(__dirname, 'public')));
app.use(
5 changes: 0 additions & 5 deletions services/fileProcessor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { fs } from 'zx';
import path from 'path';
import { processSlogs } from './slogProcessor.js';
import { convertToSVG } from './pumlToSvgConverter.js';
@@ -15,10 +14,6 @@ export const processAndConvert = async ({ inputFile, res }) => {
let outputFile, svgFilePath, svgDirPath;

try {
if (!fs.existsSync(uploadDir)) {
fs.mkdirSync(uploadDir);
}

outputFile = `${uploadDir}/processed-${uniqueSuffix}.puml`;
console.log('Processing Slogs....');
await processSlogs({ inputFile, outputFile });

0 comments on commit fab64d7

Please sign in to comment.