From d812cff5fc38301b795be5d99ad5c36a6b76cf70 Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Thu, 23 Apr 2020 10:25:59 +0200 Subject: [PATCH] Rename homeserver_url to endpoint_url in dataProvider Change-Id: I86441cd90e9b9b6b04ba2d28fee12a1cfa0684a7 --- src/synapse/dataProvider.js | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index 303d25c..7e60414 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -85,8 +85,8 @@ const dataProvider = { const res = resourceMap[resource]; - const homeserver_url = homeserver + res.path; - const url = `${homeserver_url}?${stringify(query)}`; + const endpoint_url = homeserver + res.path; + const url = `${endpoint_url}?${stringify(query)}`; return jsonClient(url).then(({ json }) => ({ data: json[res.data].map(res.map), @@ -101,8 +101,8 @@ const dataProvider = { const res = resourceMap[resource]; - const homeserver_url = homeserver + res.path; - return jsonClient(`${homeserver_url}/${params.id}`).then(({ json }) => ({ + const endpoint_url = homeserver + res.path; + return jsonClient(`${endpoint_url}/${params.id}`).then(({ json }) => ({ data: res.map(json), })); }, @@ -114,9 +114,9 @@ const dataProvider = { const res = resourceMap[resource]; - const homeserver_url = homeserver + res.path; + const endpoint_url = homeserver + res.path; return Promise.all( - params.ids.map(id => jsonClient(`${homeserver_url}/${id}`)) + params.ids.map(id => jsonClient(`${endpoint_url}/${id}`)) ).then(responses => ({ data: responses.map(({ json }) => res.map(json)), })); @@ -141,8 +141,8 @@ const dataProvider = { const res = resourceMap[resource]; - const homeserver_url = homeserver + res.path; - const url = `${homeserver_url}?${stringify(query)}`; + const endpoint_url = homeserver + res.path; + const url = `${endpoint_url}?${stringify(query)}`; return jsonClient(url).then(({ headers, json }) => ({ data: json, @@ -157,8 +157,8 @@ const dataProvider = { const res = resourceMap[resource]; - const homeserver_url = homeserver + res.path; - return jsonClient(`${homeserver_url}/${params.data.id}`, { + const endpoint_url = homeserver + res.path; + return jsonClient(`${endpoint_url}/${params.data.id}`, { method: "PUT", body: JSON.stringify(params.data, filterNullValues), }).then(({ json }) => ({ @@ -173,9 +173,9 @@ const dataProvider = { const res = resourceMap[resource]; - const homeserver_url = homeserver + res.path; + const endpoint_url = homeserver + res.path; return Promise.all( - params.ids.map(id => jsonClient(`${homeserver_url}/${id}`), { + params.ids.map(id => jsonClient(`${endpoint_url}/${id}`), { method: "PUT", body: JSON.stringify(params.data, filterNullValues), }) @@ -191,8 +191,8 @@ const dataProvider = { const res = resourceMap[resource]; - const homeserver_url = homeserver + res.path; - return jsonClient(`${homeserver_url}/${params.data.id}`, { + const endpoint_url = homeserver + res.path; + return jsonClient(`${endpoint_url}/${params.data.id}`, { method: "PUT", body: JSON.stringify(params.data, filterNullValues), }).then(({ json }) => ({ @@ -209,16 +209,16 @@ const dataProvider = { if ("delete" in res) { const del = res["delete"](params.id); - const homeserver_url = homeserver + del.endpoint; - return jsonClient(homeserver_url, { + const endpoint_url = homeserver + del.endpoint; + return jsonClient(endpoint_url, { method: del.method, body: JSON.stringify(del.body), }).then(({ json }) => ({ data: json, })); } else { - const homeserver_url = homeserver + res.path; - return jsonClient(`${homeserver_url}/${params.id}`, { + const endpoint_url = homeserver + res.path; + return jsonClient(`${endpoint_url}/${params.id}`, { method: "DELETE", body: JSON.stringify(params.data, filterNullValues), }).then(({ json }) => ({ @@ -238,8 +238,8 @@ const dataProvider = { return Promise.all( params.ids.map(id => { const del = res["delete"](id); - const homeserver_url = homeserver + del.endpoint; - return jsonClient(homeserver_url, { + const endpoint_url = homeserver + del.endpoint; + return jsonClient(endpoint_url, { method: del.method, body: JSON.stringify(del.body), }); @@ -248,10 +248,10 @@ const dataProvider = { data: responses.map(({ json }) => json), })); } else { - const homeserver_url = homeserver + res.path; + const endpoint_url = homeserver + res.path; return Promise.all( params.ids.map(id => - jsonClient(`${homeserver_url}/${id}`, { + jsonClient(`${endpoint_url}/${id}`, { method: "DELETE", body: JSON.stringify(params.data, filterNullValues), })