fix(token-aggregation): resolve TypeScript build errors
- token-mapping: use createRequire(proxmox package.json) and process.cwd(), drop import.meta to allow commonjs build - Add routes/bridge.ts stub (status + metrics) so server.ts import resolves - Add config/cross-chain-bridges.ts with BridgeConfig/BridgeLane and CHAIN_138_BRIDGES from env - cross-chain-indexer: import BridgeLane, add explicit types for .find/.map callbacks, bridgeType fallback to b.type Made-with: Cursor
This commit is contained in:
26
services/token-aggregation/src/api/routes/bridge.ts
Normal file
26
services/token-aggregation/src/api/routes/bridge.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Bridge API: cross-chain bridge status and metrics.
|
||||
* GET /api/v1/bridge/status, /api/v1/bridge/metrics — stubbed or delegated to cross-chain report.
|
||||
*/
|
||||
|
||||
import { Router, Request, Response } from 'express';
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
router.get('/status', (_req: Request, res: Response) => {
|
||||
res.json({
|
||||
ok: true,
|
||||
bridges: [],
|
||||
message: 'Bridge status: use /api/v1/report/cross-chain for volume/lanes.',
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/metrics', (_req: Request, res: Response) => {
|
||||
res.json({
|
||||
ok: true,
|
||||
lanes: [],
|
||||
message: 'Bridge metrics: use /api/v1/report/cross-chain for aggregated data.',
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -6,17 +6,15 @@
|
||||
|
||||
import { Router, Request, Response } from 'express';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { createRequire } from 'module';
|
||||
import { cacheMiddleware } from '../middleware/cache';
|
||||
|
||||
const router: Router = Router();
|
||||
const require = createRequire(import.meta.url);
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/** Resolve path to repo root (proxmox) from token-aggregation src/api/routes -> 5 levels up */
|
||||
const PROXMOX_ROOT = path.resolve(__dirname, '../../../../../');
|
||||
/** Repo root (proxmox): when run from token-aggregation cwd, 2 levels up to smom-dbis-138, 1 more to proxmox */
|
||||
const PROXMOX_ROOT = path.resolve(process.cwd(), '../../..');
|
||||
const LOADER_PATH = path.join(PROXMOX_ROOT, 'config', 'token-mapping-loader.cjs');
|
||||
const requireLoader = createRequire(path.join(PROXMOX_ROOT, 'package.json'));
|
||||
|
||||
function loadMultichainLoader(): {
|
||||
getTokenMappingForPair: (from: number, to: number) => { tokens: unknown[]; addressMapFromTo: Record<string, string>; addressMapToFrom: Record<string, string> } | null;
|
||||
@@ -24,7 +22,7 @@ function loadMultichainLoader(): {
|
||||
getMappedAddress: (from: number, to: number, addr: string) => string | undefined;
|
||||
} | null {
|
||||
try {
|
||||
const loader = require(LOADER_PATH);
|
||||
const loader = requireLoader(LOADER_PATH);
|
||||
if (loader?.getTokenMappingForPair && loader?.getAllMultichainPairs && loader?.getMappedAddress) {
|
||||
return loader;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user