-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.old.js
50 lines (44 loc) · 1.29 KB
/
server.old.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import express from 'express';
import fs from 'fs/promises';
import path from 'path';
import ExpressBridge from './ExpressBridge.js';
import { log } from 'node:console';
import { parseFiles } from './worker.mjs';
import http from 'http';
import { Server } from 'socket.io';
import selectFolderDialog from './utils/folderSelect.js';
const app = express();
const PORT = process.env.PORT || 3000;
const server = http.createServer(app);
const io = new Server(server, {
cors: {
origin: "*",
methods: ["GET", "POST"],
},
maxHttpBufferSize: 1e8,
});
const state = {
files: [],
folders: [],
targetPath: "",
}
const bridge = new ExpressBridge(io);
bridge.registerHandler('get-files-and-folders', async (args) => {
const { folder, includeFolders } = args;
console.log(args);
try {
const files = await readFilesAndFolders(folder, includeFolders);
return { parsedFiles: files };
} catch (error) {
throw new Error(`Failed to read files and folders: ${error.toString()}`);
}
});
const readFilesAndFolders = (folderPath, includeFolders) => {
return new Promise((resolve, reject) => {
console.log(folderPath);
resolve(["ege"])
});
};
server.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});