Repository navigation
Expand file tree
/
Copy pathserver.js
More file actions
80 lines (65 loc) · 2.87 KB
/
Copy pathserver.js
File metadata and controls
80 lines (65 loc) · 2.87 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* FlowASM Server
* Main entry point for the unified n8n-style platform
*/
import express from 'express';
import { readFile } from 'fs/promises';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { WorkflowRunner } from './core/runner.js';
import { createAPI } from './core/api.js';
import { AsmSandboxConnector } from './engines/asm-sandbox/adapter.js';
import { TK5Connector } from './connectors/tk5/connector.js';
import { ZOSConnector } from './connectors/zos/connector.js';
import { ZeroFrameConnector } from './connectors/zeroframe/connector.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const PORT = process.env.PORT || 3000;
// Initialize runner and connectors
const runner = new WorkflowRunner();
// Register connectors
runner.registerConnector('asm', new AsmSandboxConnector());
runner.registerConnector('tk5', new TK5Connector());
runner.registerConnector('zos', new ZOSConnector());
runner.registerConnector('zeroframe', new ZeroFrameConnector());
runner.initialize();
// Load demo workflows
async function loadDemoWorkflows() {
const workflowFiles = ['payroll-demo', 'tk5-demo', 'zos-integration'];
for (const file of workflowFiles) {
try {
const content = await readFile(join(__dirname, 'workflows', `${file}.json`), 'utf-8');
const workflow = JSON.parse(content);
runner.loadWorkflow(workflow);
console.log(`✓ Loaded workflow: ${workflow.name}`);
} catch (error) {
console.log(`⚠ Could not load ${file}.json: ${error.message}`);
}
}
}
// Create Express app
const app = express();
app.use(express.json());
app.use(express.static(join(__dirname, 'ui')));
// API routes
app.use('/api', createAPI(runner));
// Start server
async function start() {
await loadDemoWorkflows();
app.listen(PORT, () => {
console.log(`
╔═══════════════════════════════════════════════════════╗
║ FlowASM Server Started ║
╚═══════════════════════════════════════════════════════╝
🚀 Server: http://localhost:${PORT}
📊 API: http://localhost:${PORT}/api/health
🎨 UI: http://localhost:${PORT}
Connectors:
• asm-sandbox: ${runner.connectors.asm.isAvailable ? '✓ Available' : '✗ Unavailable'}
• tk5: ${runner.connectors.tk5.isAvailable ? '✓ Available' : '✗ Stubbed'}
• zos: ${runner.connectors.zos.isAvailable ? '✓ Available' : '✗ Stubbed'}
• zeroframe: ${runner.connectors.zeroframe.isAvailable ? '✓ Available' : '✗ Stubbed'}
Ready for workflows! 🎃
`);
});
}
start().catch(console.error);