dashboard cleanup
This commit is contained in:
parent
660a2a1ec2
commit
56e3938561
36 changed files with 1002 additions and 3481 deletions
|
|
@ -11,6 +11,26 @@ const logger = getLogger('exchange-routes');
|
|||
|
||||
export const exchangeRoutes = new Hono();
|
||||
|
||||
// Get all master exchanges
|
||||
exchangeRoutes.get('/api/exchanges', async c => {
|
||||
try {
|
||||
await connectMongoDB();
|
||||
const db = getDatabase();
|
||||
const collection = db.collection<MasterExchange>('masterExchanges');
|
||||
|
||||
const exchanges = await collection.find({}).toArray();
|
||||
|
||||
return c.json({
|
||||
data: exchanges,
|
||||
count: exchanges.length,
|
||||
status: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error('Error getting all exchanges', { error });
|
||||
return c.json({ error: 'Internal server error' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// Get master exchange details
|
||||
exchangeRoutes.get('/api/exchanges/:masterExchangeId', async c => {
|
||||
try {
|
||||
|
|
@ -91,12 +111,10 @@ exchangeRoutes.get('/api/exchanges/source/:sourceName', async c => {
|
|||
}));
|
||||
|
||||
return c.json({
|
||||
data: exchanges,
|
||||
count: exchanges.length,
|
||||
status: 'success',
|
||||
data: {
|
||||
sourceName,
|
||||
count: exchanges.length,
|
||||
exchanges,
|
||||
},
|
||||
sourceName,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error('Error getting source exchanges', { error });
|
||||
|
|
@ -104,6 +122,45 @@ exchangeRoutes.get('/api/exchanges/source/:sourceName', async c => {
|
|||
}
|
||||
});
|
||||
|
||||
// Add source mapping to an exchange
|
||||
exchangeRoutes.post('/api/exchanges/:masterExchangeId/mappings', async c => {
|
||||
try {
|
||||
const masterExchangeId = c.req.param('masterExchangeId');
|
||||
const { sourceName, sourceData } = await c.req.json();
|
||||
|
||||
if (!sourceName || !sourceData || !sourceData.id) {
|
||||
return c.json({ error: 'sourceName and sourceData with id are required' }, 400);
|
||||
}
|
||||
|
||||
await connectMongoDB();
|
||||
const db = getDatabase();
|
||||
const collection = db.collection<MasterExchange>('masterExchanges');
|
||||
|
||||
const result = await collection.updateOne(
|
||||
{ masterExchangeId },
|
||||
{
|
||||
$set: {
|
||||
[`sourceMappings.${sourceName}`]: sourceData,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (result.matchedCount === 0) {
|
||||
return c.json({ error: 'Exchange not found' }, 404);
|
||||
}
|
||||
|
||||
return c.json({
|
||||
status: 'success',
|
||||
message: 'Source mapping added successfully',
|
||||
data: { masterExchangeId, sourceName, sourceData },
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error('Error adding source mapping', { error });
|
||||
return c.json({ error: 'Internal server error' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// Trigger exchange sync
|
||||
exchangeRoutes.post('/api/exchanges/sync', async c => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue