From ce5f21fe49e3129d40a87910ccf4cd4cb380bd22 Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Thu, 6 Jun 2019 16:22:19 +0200 Subject: [PATCH] =?UTF-8?q?Dynamic=20retribute=20API=C2=A0endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/components/Suggestions.vue | 9 +++++---- src/config.js | 3 +++ vue.config.js | 9 +++++++++ yarn.lock | 19 +++++++++++++++++++ 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/config.js create mode 100644 vue.config.js diff --git a/package.json b/package.json index be176be..3e5c43d 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@vue/test-utils": "1.0.0-beta.29", "babel-eslint": "^10.0.1", "chai": "^4.1.2", + "dotenv-webpack": "^1.7.0", "eslint": "^5.16.0", "eslint-plugin-vue": "^5.0.0", "vue-template-compiler": "^2.6.10" diff --git a/src/components/Suggestions.vue b/src/components/Suggestions.vue index 6ae68ce..ce426ea 100644 --- a/src/components/Suggestions.vue +++ b/src/components/Suggestions.vue @@ -60,6 +60,7 @@ <script> import sources from '@/sources' +import config from '@/config' import orderBy from 'lodash/orderBy' import pull from 'lodash/pull' import chunk from 'lodash/chunk' @@ -93,8 +94,8 @@ export default { let self = this let suggestions = this.allSuggestions.filter((s) => { let f = true - if (self.filters.retributeOnly) { - f = !!this.retributeProfiles[s.fullId] + if (self.filters.retributeOnly != null) { + f = !!this.retributeProfiles[s.fullId] === self.filters.retributeOnly } return f }) @@ -191,7 +192,7 @@ export default { self.loadingRetributeProfiles.push(id) }) const client = axios.create() - let url = `http://localhost:8000/api/v1/search/` + let url = config.RetributeAPIUrl + `v1/search/` let response try { response = await client.post(url, {lookups: ids}) @@ -209,7 +210,7 @@ export default { async lookup (id) { this.loadingRetributeProfiles.push(id) const client = axios.create() - let url = `http://localhost:8000/api/v1/search/${id}` + let url = config.RetributeAPIUrl + `v1/search/${id}` try { const response = await client.get(url) this.$set(this.retributeProfiles, id, response.data) diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..e0ff8ad --- /dev/null +++ b/src/config.js @@ -0,0 +1,3 @@ +export default { + RetributeAPIUrl: process.env.RETRIBUTE_API_URL || 'https://api.retribute.me/' +} diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..2096ab4 --- /dev/null +++ b/vue.config.js @@ -0,0 +1,9 @@ +const Dotenv = require('dotenv-webpack'); + +module.exports = { + configureWebpack: { + plugins: [ + new Dotenv() + ] + } +} diff --git a/yarn.lock b/yarn.lock index c2858a2..07e1975 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2966,11 +2966,30 @@ dot-prop@^4.1.1: dependencies: is-obj "^1.0.0" +dotenv-defaults@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/dotenv-defaults/-/dotenv-defaults-1.0.2.tgz#441cf5f067653fca4bbdce9dd3b803f6f84c585d" + integrity sha512-iXFvHtXl/hZPiFj++1hBg4lbKwGM+t/GlvELDnRtOFdjXyWP7mubkVr+eZGWG62kdsbulXAef6v/j6kiWc/xGA== + dependencies: + dotenv "^6.2.0" + dotenv-expand@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0" integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA== +dotenv-webpack@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/dotenv-webpack/-/dotenv-webpack-1.7.0.tgz#4384d8c57ee6f405c296278c14a9f9167856d3a1" + integrity sha512-wwNtOBW/6gLQSkb8p43y0Wts970A3xtNiG/mpwj9MLUhtPCQG6i+/DSXXoNN7fbPCU/vQ7JjwGmgOeGZSSZnsw== + dependencies: + dotenv-defaults "^1.0.2" + +dotenv@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064" + integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w== + dotenv@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-7.0.0.tgz#a2be3cd52736673206e8a85fb5210eea29628e7c" -- GitLab