47 lines
No EOL
1.3 KiB
JavaScript
47 lines
No EOL
1.3 KiB
JavaScript
// Test Frontend Server
|
|
const express = require('express');
|
|
const path = require('path');
|
|
const cors = require('cors');
|
|
|
|
const fs = require('fs');
|
|
|
|
const app = express();
|
|
app.use(cors());
|
|
app.use(express.static('public'));
|
|
app.use(express.json());
|
|
|
|
// Serve circuit files from the shared volume
|
|
app.use('/circuits', express.static('/app/circuits/build'));
|
|
app.use('/keys', express.static('/app/keys'));
|
|
|
|
// Serve verification key as JSON
|
|
app.get('/api/circuit/vkey', (req, res) => {
|
|
try {
|
|
const vKeyPath = '/app/keys/license_verification_verification_key.json';
|
|
if (fs.existsSync(vKeyPath)) {
|
|
const vKey = JSON.parse(fs.readFileSync(vKeyPath, 'utf8'));
|
|
res.json(vKey);
|
|
} else {
|
|
res.status(404).json({ error: 'Verification key not found' });
|
|
}
|
|
} catch (error) {
|
|
res.status(500).json({ error: error.message });
|
|
}
|
|
});
|
|
|
|
// Serve the test UI
|
|
app.get('/', (req, res) => {
|
|
res.sendFile(path.join(__dirname, 'public', 'index.html'));
|
|
});
|
|
|
|
// Health check
|
|
app.get('/health', (req, res) => {
|
|
res.json({ status: 'healthy' });
|
|
});
|
|
|
|
const PORT = process.env.PORT || 3000;
|
|
app.listen(PORT, () => {
|
|
console.log(`Test UI server listening on port ${PORT}`);
|
|
console.log(`Open http://localhost:${PORT} to access the test interface`);
|
|
});
|
|
|