streamby-core 0.24.10 → 0.24.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -54,33 +54,11 @@ function exportRouter(config) {
|
|
|
54
54
|
if (!currentProject) {
|
|
55
55
|
return res.status(404).json({ message: 'Project not found.' });
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
if (exportMetadata.credentialId) {
|
|
59
|
-
const credential = currentProject.credentials?.find((cred) => cred.id === exportMetadata.credentialId);
|
|
60
|
-
if (!credential) {
|
|
61
|
-
return res.status(404).json({ message: `Credential with ID ${exportMetadata.credentialId} not found.` });
|
|
62
|
-
}
|
|
63
|
-
const decryptedValue = (0, encryption_1.decrypt)(credential.encryptedValue);
|
|
64
|
-
const authPrefix = exportMetadata.prefix ? `${exportMetadata.prefix} ` : 'Bearer ';
|
|
65
|
-
headers = {
|
|
66
|
-
'Authorization': `${authPrefix}${decryptedValue}`,
|
|
67
|
-
'Content-Type': 'application/json',
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
const response = await (0, node_fetch_1.default)(exportMetadata.apiUrl, { headers });
|
|
72
|
-
if (!response.ok) {
|
|
73
|
-
throw new Error(`Failed to fetch from external API: ${response.statusText}`);
|
|
74
|
-
}
|
|
75
|
-
const responseData = await response.json();
|
|
76
|
-
data = { responseData, name: exportMetadata.name, createdAt: exportMetadata.createdAt, updatedAt: exportMetadata.updatedAt, type: exportMetadata.type, collectionName: exportMetadata.collectionName };
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
return res.status(500).json({ message: 'Failed to fetch from external API', details: error.message });
|
|
80
|
-
}
|
|
57
|
+
data = { name: exportMetadata.name, createdAt: exportMetadata.createdAt, updatedAt: exportMetadata.updatedAt, type: exportMetadata.type, collectionName: exportMetadata.collectionName };
|
|
81
58
|
}
|
|
82
59
|
else {
|
|
83
|
-
|
|
60
|
+
const rawData = await db.collection(exportMetadata.collectionName).findOne({ _id: new mongodb_1.ObjectId(exportId) });
|
|
61
|
+
data = rawData ? { json: rawData.json, name: rawData.name, method: rawData.method, collectionName: rawData.collectionName, createdAt: rawData.createdAt, updatedAt: rawData.updatedAt, type: exportMetadata.type } : null;
|
|
84
62
|
}
|
|
85
63
|
}
|
|
86
64
|
else if (project.dbType === 'sql') {
|
|
@@ -90,20 +68,11 @@ function exportRouter(config) {
|
|
|
90
68
|
return res.status(404).json({ message: 'Export data not found' });
|
|
91
69
|
}
|
|
92
70
|
let responseData;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
responseData = {
|
|
102
|
-
...data,
|
|
103
|
-
allowedOrigin: exportMetadata.allowedOrigin,
|
|
104
|
-
private: exportMetadata.private,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
71
|
+
responseData = {
|
|
72
|
+
...data,
|
|
73
|
+
allowedOrigin: exportMetadata.allowedOrigin,
|
|
74
|
+
private: exportMetadata.private,
|
|
75
|
+
};
|
|
107
76
|
res.json({
|
|
108
77
|
data: responseData,
|
|
109
78
|
message: 'Export data fetched successfully',
|