-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmock-server.js
More file actions
44 lines (39 loc) · 1.15 KB
/
mock-server.js
File metadata and controls
44 lines (39 loc) · 1.15 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
// Simple mock server for testing CLI
const express = require('express');
const app = express();
app.use(express.json());
// Mock endpoints
app.get('/health', (req, res) => {
res.json({ status: 'ok' });
});
app.post('/projects', (req, res) => {
res.json({
org_id: 'org_mock123',
project_id: 'proj_mock456',
project_name: req.body.project_name,
created: true
});
});
app.get('/decrypt', (req, res) => {
res.json({
env_content: 'DATABASE_URL=postgres://localhost:5432/db\nAPI_KEY=sk-mock-key-123',
decrypt_key: Buffer.from('mock-decrypt-key').toString('base64'),
expires_at: new Date(Date.now() + 86400000).toISOString()
});
});
app.post('/variables/push', (req, res) => {
const result = {};
for (const key of Object.keys(req.body.variables)) {
result[key] = {
resource_id: `res_${key}_${Date.now()}`,
success: true
};
}
res.json({ success: true, variables: result });
});
const PORT = 3001;
app.listen(PORT, () => {
console.log(`🚀 Mock Capy service running on http://localhost:${PORT}`);
console.log('\nSet environment variable:');
console.log(`export CAPY_API_URL=http://localhost:${PORT}`);
});