Skip to content

Commit c0cc234

Browse files
authored
Merge pull request #104 from menawar/feat/88-service-catalog
feat(backend): implement service catalog (#88)
2 parents c00854f + 45a9be4 commit c0cc234

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

backend/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import dotenv from 'dotenv';
44
import { verificationRouter } from './routes/verification.js';
55
import { invoiceRouter } from './routes/invoice.js';
66
import { stellarRouter } from './routes/stellar.js';
7+
import { catalogRouter } from './routes/catalog.js';
78

89
dotenv.config();
910

@@ -22,6 +23,7 @@ app.get('/health', (_req, res) => {
2223
app.use('/api/v1/verification', verificationRouter);
2324
app.use('/api/v1/invoice', invoiceRouter);
2425
app.use('/api/v1/stellar', stellarRouter);
26+
app.use('/api/v1/catalog', catalogRouter);
2527

2628
app.listen(PORT, () => {
2729
console.log(`AgenticPay backend running on port ${PORT}`);

backend/src/routes/catalog.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Router } from 'express';
2+
import { getCatalog } from '../services/catalog.js';
3+
4+
export const catalogRouter = Router();
5+
6+
catalogRouter.get('/', (req, res) => {
7+
try {
8+
const catalog = getCatalog();
9+
res.json(catalog);
10+
} catch (error) {
11+
console.error('Catalog error:', error);
12+
res.status(500).json({ message: 'Failed to fetch catalog' });
13+
}
14+
});

backend/src/services/catalog.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { readFileSync } from 'fs';
2+
import { join } from 'path';
3+
4+
let cachedVersion = 'unknown';
5+
6+
try {
7+
// Use process.cwd() as we can safely assume this runs from backend/ directory
8+
const pkgPath = join(process.cwd(), 'package.json');
9+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
10+
cachedVersion = pkg.version || '0.1.0';
11+
} catch (e) {
12+
console.warn('Could not read package.json version, defaulting to 0.1.0');
13+
cachedVersion = '0.1.0';
14+
}
15+
16+
export function getCatalog() {
17+
return {
18+
version: cachedVersion,
19+
services: [
20+
{
21+
id: 'verification',
22+
name: 'AI-powered work verification',
23+
capabilities: ['Verify work based on milestone descriptions and repository URLs'],
24+
dependencies: ['OpenAI API'],
25+
},
26+
{
27+
id: 'invoice',
28+
name: 'Invoice Generation',
29+
capabilities: ['Generate professional invoices with itemized line items and summaries based on hours and rates'],
30+
dependencies: ['OpenAI API'],
31+
},
32+
{
33+
id: 'stellar',
34+
name: 'Stellar Network Operations',
35+
capabilities: ['Retrieve account info (balances, sequence)', 'Get transaction status via hash'],
36+
dependencies: ['Stellar SDK', 'Stellar Horizon'],
37+
}
38+
]
39+
};
40+
}

0 commit comments

Comments
 (0)