Files
pulse-signage/src/web/routes/data-sources/api-sources/duplicate.js
T
lzstealth 196c640f9b
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m47s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 31s
Release 2.8.7
2026-08-22 01:33:35 +01:00

38 lines
1.3 KiB
JavaScript

// API source duplication helpers.
function buildDuplicateApiSourceName(sourceName) {
const baseName = 'Copy of ' + String(sourceName || '').trim();
return baseName;
}
function buildDuplicateApiSource(apiSource, duplicateName) {
return Object.assign({}, apiSource, {
id: null,
name: duplicateName,
apiUrl: apiSource.api_url || '',
lastPulledAt: null,
lastPullError: '',
lastResponseStatus: null,
lastResponseContentType: '',
lastResponseJson: '',
authMethod: apiSource.auth_method || 'none',
authUsername: apiSource.auth_username || '',
authPassword: apiSource.auth_password || '',
authBearerToken: apiSource.auth_bearer_token || '',
authHeaderName: apiSource.auth_header_name || 'X-API-Key',
authHeaderValue: apiSource.auth_header_value || '',
requestMethod: apiSource.request_method || 'GET',
requestBodyJson: apiSource.request_body_json || '',
tokenUrl: apiSource.token_url || '',
tokenRequestBodyJson: apiSource.token_request_body_json || '',
tokenResponsePath: apiSource.token_response_path || 'access_token',
tokenHeaderName: apiSource.token_header_name || 'Authorization',
tokenHeaderPrefix: apiSource.token_header_prefix || 'Bearer',
itemsPath: apiSource.items_path || ''
});
}
module.exports = {
buildDuplicateApiSourceName,
buildDuplicateApiSource
};