MCPcopy Create free account
hub / github.com/bytebase/dbhub / getSource

Function getSource

src/api/sources.ts:103–128  ·  view source on GitHub ↗
(req: Request, res: Response)

Source from the content-addressed store, hash-verified

101 * Get a specific data source by ID
102 */
103export function getSource(req: Request, res: Response): void {
104 try {
105 const sourceId = req.params.sourceId;
106
107 // Get source config - will be null if source doesn't exist
108 const sourceConfig = ConnectorManager.getSourceConfig(sourceId);
109 if (!sourceConfig) {
110 const errorResponse: ErrorResponse = {
111 error: "Source not found",
112 source_id: sourceId,
113 };
114 res.status(404).json(errorResponse);
115 return;
116 }
117
118 // Transform and return
119 const dataSource = transformSourceConfig(sourceConfig);
120 res.json(dataSource);
121 } catch (error) {
122 console.error(`Error getting source ${req.params.sourceId}:`, error);
123 const errorResponse: ErrorResponse = {
124 error: error instanceof Error ? error.message : "Internal server error",
125 };
126 res.status(500).json(errorResponse);
127 }
128}

Callers

nothing calls this directly

Calls 2

transformSourceConfigFunction · 0.85
getSourceConfigMethod · 0.80

Tested by

no test coverage detected