Browse Source

Merge pull request #77 from mayankchhabra/env

Environment variables name change
patch-2
Mayank Chhabra 4 years ago
committed by GitHub
parent
commit
a00194485f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .env
  2. 4
      .env.production
  3. 4
      .env.staging
  4. 5
      package.json
  5. 2
      src/components/BitcoinWallet.vue
  6. 2
      src/components/Channels/Channel.vue
  7. 4
      src/components/Channels/Manage.vue
  8. 4
      src/components/Channels/Open.vue
  9. 8
      src/components/LightningWallet.vue
  10. 6
      src/helpers/api.js
  11. 22
      src/store/modules/bitcoin.js
  12. 20
      src/store/modules/lightning.js
  13. 4
      src/store/modules/system.js
  14. 14
      src/store/modules/user.js

4
.env

@ -1,2 +1,2 @@
VUE_APP_API_URL=http://localhost:3005
VUE_APP_SYSTEM_API_URL=http://localhost:3333
VUE_APP_MIDDLEWARE_API_URL=http://localhost:3005
VUE_APP_MANAGER_API_URL=http://localhost:3006

4
.env.production

@ -1,2 +1,2 @@
VUE_APP_API_URL=/api
VUE_APP_SYSTEM_API_URL=/manager-api
VUE_APP_MIDDLEWARE_API_URL=/api
VUE_APP_MANAGER_API_URL=/manager-api

4
.env.staging

@ -1,2 +1,2 @@
VUE_APP_API_URL=/api
VUE_APP_SYSTEM_API_URL=/manager-api
VUE_APP_MIDDLEWARE_API_URL=/api
VUE_APP_MANAGER_API_URL=/manager-api

5
package.json

@ -5,8 +5,7 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --mode production",
"lint": "vue-cli-service lint",
"deploy-local": "vue-cli-service build --mode production && rsync -aP --delete dist/ umbrel@umbrel.local:/home/umbrel/nginx/www"
"lint": "vue-cli-service lint"
},
"dependencies": {
"animate.css": "^3.7.2",
@ -60,4 +59,4 @@
"> 1%",
"last 2 versions"
]
}
}

2
src/components/BitcoinWallet.vue

@ -661,7 +661,7 @@ export default {
try {
const res = await API.post(
`${process.env.VUE_APP_API_URL}/v1/lnd/transaction`,
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/transaction`,
payload
);
const withdrawTx = res.data;

2
src/components/Channels/Channel.vue

@ -120,7 +120,7 @@ export default {
async updateNodeAlias() {
if (this.channel.remotePubkey) {
const nodeAlias = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/info/alias?pubkey=${this.channel.remotePubkey}`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/info/alias?pubkey=${this.channel.remotePubkey}`
);
if (nodeAlias) {
this.alias = nodeAlias.alias;

4
src/components/Channels/Manage.vue

@ -169,7 +169,7 @@ export default {
},
async mounted() {
const nodeAlias = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/info/alias?pubkey=${this.channel.remotePubkey}`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/info/alias?pubkey=${this.channel.remotePubkey}`
);
if (nodeAlias) {
this.alias = nodeAlias.alias;
@ -202,7 +202,7 @@ export default {
force: !this.channel.active // Avoids force closing if channel is active
};
await API.delete(
`${process.env.VUE_APP_API_URL}/v1/lnd/channel/close`,
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/channel/close`,
payload
);
this.$emit("channelclose");

4
src/components/Channels/Open.vue

@ -166,7 +166,7 @@ export default {
try {
await API.post(
`${process.env.VUE_APP_API_URL}/v1/lnd/channel/open`,
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/channel/open`,
payload
);
this.isOpening = false;
@ -203,7 +203,7 @@ export default {
try {
estimates = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/channel/estimateFee?confTarget=0&amt=${this.fundingAmount}`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/channel/estimateFee?confTarget=0&amt=${this.fundingAmount}`
);
} catch (error) {
if (error.response && error.response.data) {

8
src/components/LightningWallet.vue

@ -816,7 +816,7 @@ export default {
try {
const res = await API.post(
`${process.env.VUE_APP_API_URL}/v1/lnd/lightning/payInvoice`,
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/lightning/payInvoice`,
payload
);
if (res.data.paymentError) {
@ -857,7 +857,7 @@ export default {
setTimeout(async () => {
try {
const res = await API.post(
`${process.env.VUE_APP_API_URL}/v1/lnd/lightning/addInvoice`,
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/lightning/addInvoice`,
payload
);
this.receive.invoiceQR = this.receive.paymentRequest =
@ -900,7 +900,7 @@ export default {
this.loading = true;
const fetchedInvoice = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/lightning/invoice?paymentRequest=${this.send.paymentRequest}`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/lightning/invoice?paymentRequest=${this.send.paymentRequest}`
);
if (!fetchedInvoice) {
@ -981,7 +981,7 @@ export default {
}
this.receive.invoiceStatusPollerInprogress = true;
const invoices = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/lightning/invoices`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/lightning/invoices`
);
if (invoices && invoices.length) {
//search for invoice

6
src/helpers/api.js

@ -17,7 +17,7 @@ axios.interceptors.response.use(function (response) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
//logout user if lnd is locked
if (error.response.status === 403 && error.config.url.startsWith(`${process.env.VUE_APP_API_URL}/v1/lnd`) && error.response.data === "Must unlock wallet") {
if (error.response.status === 403 && error.config.url.startsWith(`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd`) && error.response.data === "Must unlock wallet") {
store.dispatch('user/logout')
return Promise.reject(error);
}
@ -29,12 +29,12 @@ axios.interceptors.response.use(function (response) {
// Return the same 401 back if user is trying to login with incorrect password
if (error.config.url === `${process.env.VUE_APP_SYSTEM_API_URL}/v1/account/login`) {
if (error.config.url === `${process.env.VUE_APP_MANAGER_API_URL}/v1/account/login`) {
return Promise.reject(error);
}
// Logout user if token refresh didn't work
if (error.config.url === `${process.env.VUE_APP_SYSTEM_API_URL}/v1/account/refresh`) {
if (error.config.url === `${process.env.VUE_APP_MANAGER_API_URL}/v1/account/refresh`) {
store.dispatch('user/logout');
return Promise.reject(error);
}

22
src/store/modules/bitcoin.js

@ -183,7 +183,7 @@ const mutations = {
const actions = {
async getStatus({ commit }) {
const status = await API.get(
`${process.env.VUE_APP_API_URL}/v1/bitcoind/info/status`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/bitcoind/info/status`
);
if (status) {
@ -199,7 +199,7 @@ const actions = {
// We can only make this request when bitcoind is operational
if (state.operational) {
const addresses = await API.get(
`${process.env.VUE_APP_API_URL}/v1/bitcoind/info/addresses`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/bitcoind/info/addresses`
);
// Default onion address to not found.
@ -220,7 +220,7 @@ const actions = {
async getSync({ commit, state }) {
if (state.operational) {
const sync = await API.get(
`${process.env.VUE_APP_API_URL}/v1/bitcoind/info/sync`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/bitcoind/info/sync`
);
if (sync) {
@ -248,7 +248,7 @@ const actions = {
//TODO: Fetch only new blocks
const latestThreeBlocks = await API.get(
`${process.env.VUE_APP_API_URL}/v1/bitcoind/info/blocks?from=${currentBlock - 2}&to=${currentBlock}`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/bitcoind/info/blocks?from=${currentBlock - 2}&to=${currentBlock}`
);
if (!latestThreeBlocks.blocks) {
@ -263,7 +263,7 @@ const actions = {
async getVersion({ commit, state }) {
if (state.operational) {
const version = await API.get(
`${process.env.VUE_APP_API_URL}/v1/bitcoind/info/version`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/bitcoind/info/version`
);
if (version) {
@ -275,7 +275,7 @@ const actions = {
async getPeers({ commit, state }) {
if (state.operational) {
const peers = await API.get(
`${process.env.VUE_APP_API_URL}/v1/bitcoind/info/connections`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/bitcoind/info/connections`
);
if (peers) {
@ -287,7 +287,7 @@ const actions = {
async getStats({ commit, state }) {
if (state.operational) {
const stats = await API.get(
`${process.env.VUE_APP_API_URL}/v1/bitcoind/info/stats`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/bitcoind/info/stats`
);
if (stats) {
@ -309,7 +309,7 @@ const actions = {
async getBalance({ commit, state }) {
if (state.operational) {
const balance = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/wallet/btc`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/wallet/btc`
);
if (balance) {
@ -321,7 +321,7 @@ const actions = {
async getTransactions({ commit, state }) {
if (state.operational) {
const transactions = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/transaction`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/transaction`
);
commit("transactions", transactions);
}
@ -340,7 +340,7 @@ const actions = {
async getDepositAddress({ commit, state }) {
if (state.operational) {
const { address } = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/address`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/address`
);
if (address) {
@ -352,7 +352,7 @@ const actions = {
async getFees({ commit, state }, { address, confTarget, amt, sweep }) {
if (state.operational) {
const fees = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/transaction/estimateFee?address=${address}&confTarget=${confTarget}&amt=${amt}&sweep=${sweep}`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/transaction/estimateFee?address=${address}&confTarget=${confTarget}&amt=${amt}&sweep=${sweep}`
);
if (fees) {

20
src/store/modules/lightning.js

@ -127,7 +127,7 @@ const mutations = {
const actions = {
async getStatus({ commit }) {
const status = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/info/status`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/info/status`
);
if (status) {
commit("isOperational", status.operational);
@ -137,7 +137,7 @@ const actions = {
// launch unlock modal after 30 sec
// if (!status.unlocked) {
// await sleep(30000);
// const { unlocked } = await API.get(`${process.env.VUE_APP_API_URL}/v1/lnd/info/status`);
// const { unlocked } = await API.get(`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/info/status`);
// commit('isUnlocked', unlocked);
// if (!unlocked) {
// Events.$emit('unlock-modal-open');
@ -147,7 +147,7 @@ const actions = {
//basically fetches everything
async getLndPageData({ commit, dispatch }) {
const data = await API.get(`${process.env.VUE_APP_API_URL}/v1/pages/lnd`);
const data = await API.get(`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/pages/lnd`);
if (data) {
const channels = data.channels;
@ -164,7 +164,7 @@ const actions = {
async getConnectionCode({ commit }) {
const uris = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/info/uris`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/info/uris`
);
if (uris && uris.length > 0) {
@ -180,7 +180,7 @@ const actions = {
async getBalance({ commit, state }) {
if (state.operational && state.unlocked) {
const balance = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/wallet/lightning`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/wallet/lightning`
);
if (balance) {
@ -198,7 +198,7 @@ const actions = {
rawChannels = preFetchedChannels;
} else {
rawChannels = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/channel`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/channel`
);
}
@ -285,10 +285,10 @@ const actions = {
if (state.operational && state.unlocked) {
// Get invoices and payments
const invoices = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/lightning/invoices`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/lightning/invoices`
);
const payments = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/lightning/payments`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/lightning/payments`
);
if (!invoices || !payments) {
@ -369,7 +369,7 @@ const actions = {
try {
const invoiceDetails = await API.get(
`${process.env.VUE_APP_API_URL}/v1/lnd/lightning/invoice?paymentRequest=${tx.paymentRequest}`
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/lightning/invoice?paymentRequest=${tx.paymentRequest}`
);
if (invoiceDetails && invoiceDetails.description) {
//load state's txs
@ -402,7 +402,7 @@ const actions = {
if (state.operational && !state.unlocked) {
const result = await API.post(
`${process.env.VUE_APP_API_URL}/v1/lnd/wallet/unlock`,
`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/wallet/unlock`,
{ password: plainTextPassword }
);
if (result.status === 200) {

4
src/store/modules/system.js

@ -44,14 +44,14 @@ const actions = {
}
},
async getApi({ commit }) {
const api = await API.get(`${process.env.VUE_APP_API_URL}/ping`);
const api = await API.get(`${process.env.VUE_APP_MIDDLEWARE_API_URL}/ping`);
commit("setApi", {
operational: !!(api && api.version),
version: api && api.version ? api.version : ""
});
},
async getManagerApi({ commit }) {
const api = await API.get(`${process.env.VUE_APP_SYSTEM_API_URL}/ping`);
const api = await API.get(`${process.env.VUE_APP_MANAGER_API_URL}/ping`);
commit("setManagerApi", {
operational: !!(api && api.version),
version: api && api.version ? api.version : ""

14
src/store/modules/user.js

@ -31,7 +31,7 @@ const actions = {
async login({ commit }, password) {
const { data } = await API.post(
`${process.env.VUE_APP_SYSTEM_API_URL}/v1/account/login`,
`${process.env.VUE_APP_MANAGER_API_URL}/v1/account/login`,
{ password }
);
@ -48,19 +48,19 @@ const actions = {
},
async refreshJWT({ commit }) {
const { data } = await API.post(`${process.env.VUE_APP_SYSTEM_API_URL}/v1/account/refresh`);
const { data } = await API.post(`${process.env.VUE_APP_MANAGER_API_URL}/v1/account/refresh`);
if (data && data.jwt) {
commit("setJWT", data.jwt);
}
},
async registered({ commit }) {
const { registered } = await API.get(`${process.env.VUE_APP_SYSTEM_API_URL}/v1/account/registered`);
const { registered } = await API.get(`${process.env.VUE_APP_MANAGER_API_URL}/v1/account/registered`);
commit("setRegistered", !!registered);
},
async getInfo({ commit }) {
const { name } = await API.get(`${process.env.VUE_APP_SYSTEM_API_URL}/v1/account/info`);
const { name } = await API.get(`${process.env.VUE_APP_MANAGER_API_URL}/v1/account/info`);
commit("setName", name);
},
@ -72,7 +72,7 @@ const actions = {
//get user's stored seed if already registered
if (state.registered && plainTextPassword) {
rawSeed = await API.post(`${process.env.VUE_APP_SYSTEM_API_URL}/v1/account/seed`, {
rawSeed = await API.post(`${process.env.VUE_APP_MANAGER_API_URL}/v1/account/seed`, {
password: plainTextPassword
}, false);
if (rawSeed.data) {
@ -80,7 +80,7 @@ const actions = {
}
} else {
//get a new seed if new user
rawSeed = await API.get(`${process.env.VUE_APP_API_URL}/v1/lnd/wallet/seed`);
rawSeed = await API.get(`${process.env.VUE_APP_MIDDLEWARE_API_URL}/v1/lnd/wallet/seed`);
}
if (rawSeed && rawSeed.seed) {
@ -90,7 +90,7 @@ const actions = {
async register({ commit, state }, { name, password, seed }) {
if (!state.registered) {
const result = await API.post(`${process.env.VUE_APP_SYSTEM_API_URL}/v1/account/register`, {
const result = await API.post(`${process.env.VUE_APP_MANAGER_API_URL}/v1/account/register`, {
name,
password,
seed

Loading…
Cancel
Save