Comparing version 0.12.0 to 0.13.0
# druxt | ||
## 0.13.0 | ||
### Minor Changes | ||
- 77ab204: Added ability to proxy the API | ||
```js | ||
export default { | ||
druxt: { | ||
proxy: { | ||
api: true | ||
} | ||
} | ||
}; | ||
``` | ||
Creates two proxy entries: | ||
- The JSON:API: `${ENDPOINT}` -> `${BASEURL}${ENDPOINT}` | ||
- The Decoupled Router:`/router/translate-path` -> `${BASEURL}/router/translate-path` | ||
- 77ab204: Added ability to proxy the Drupal file system | ||
```js | ||
export default { | ||
druxt: { | ||
proxy: { | ||
files: "default" | ||
} | ||
} | ||
}; | ||
``` | ||
Creates a proxy entry: | ||
- `/sites/${PATH}/files` -> `${BASEURL}/site/${PATH}/files` | ||
- c4457e1: Changed template injected module components to not use a DruxtWrapper component by default. | ||
- e7b1533: Refactored DruxtModule fetch hooks | ||
## 0.12.0 | ||
@@ -4,0 +44,0 @@ |
@@ -17,2 +17,29 @@ import chalk from 'chalk'; | ||
}; | ||
if (options.proxy) { | ||
const proxies = {}; | ||
if ((options.proxy || {}).api) { | ||
proxies[options.endpoint] = options.baseUrl; | ||
proxies["/router/translate-path"] = options.baseUrl; | ||
} | ||
if ((options.proxy || {}).files) { | ||
const filesPath = typeof options.proxy.files === "string" ? options.proxy.files : "default"; | ||
proxies[`/sites/${filesPath}/files`] = options.baseUrl; | ||
} | ||
if (this.options.proxy) { | ||
if (Array.isArray(this.options.proxy)) { | ||
this.options.proxy = [ | ||
...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`), | ||
...this.options.proxy | ||
]; | ||
} else { | ||
this.options.proxy = { | ||
...proxies, | ||
...this.options.proxy | ||
}; | ||
} | ||
} else { | ||
this.options.proxy = proxies; | ||
} | ||
this.addModule("@nuxtjs/proxy"); | ||
} | ||
this.nuxt.hook("components:dirs", (dirs) => { | ||
@@ -42,3 +69,6 @@ dirs.push({ path: join(__dirname, "components") }); | ||
} | ||
let axiosSettings = { baseURL: baseUrl }; | ||
let axiosSettings = {}; | ||
if (baseUrl && !(options.proxy || {}).api) { | ||
axiosSettings.baseURL = baseUrl; | ||
} | ||
if (typeof options.axios === "object") { | ||
@@ -143,6 +173,10 @@ axiosSettings = Object.assign(axiosSettings, options.axios); | ||
} | ||
const index = await this.axios.get(this.options.endpoint); | ||
this.index = index.data.links; | ||
if (this.index[this.options.jsonapiResourceConfig]) { | ||
const resources = await this.axios.get(this.index[this.options.jsonapiResourceConfig].href); | ||
let index = ((await this.axios.get(this.options.endpoint) || {}).data || {}).links; | ||
const baseUrl = this.options.baseUrl; | ||
index = Object.fromEntries(Object.entries(index).map(([key, value]) => { | ||
value.href = value.href.replace(baseUrl, ""); | ||
return [key, value]; | ||
})); | ||
if (index[this.options.jsonapiResourceConfig]) { | ||
const resources = await this.axios.get(index[this.options.jsonapiResourceConfig].href); | ||
for (const resourceType in resources.data.data) { | ||
@@ -158,10 +192,12 @@ const resource2 = resources.data.data[resourceType]; | ||
const id = [item.entityType, item.bundle].join("--"); | ||
this.index[id] = { | ||
index[id] = { | ||
...item, | ||
...this.index[id] | ||
...index[id] | ||
}; | ||
} | ||
} | ||
this.index = index; | ||
if (resource) { | ||
return this.index[resource] ? this.index[resource] : false; | ||
const response = this.index[resource] ? this.index[resource] : false; | ||
return response; | ||
} | ||
@@ -168,0 +204,0 @@ return this.index; |
@@ -29,2 +29,29 @@ 'use strict'; | ||
}; | ||
if (options.proxy) { | ||
const proxies = {}; | ||
if ((options.proxy || {}).api) { | ||
proxies[options.endpoint] = options.baseUrl; | ||
proxies["/router/translate-path"] = options.baseUrl; | ||
} | ||
if ((options.proxy || {}).files) { | ||
const filesPath = typeof options.proxy.files === "string" ? options.proxy.files : "default"; | ||
proxies[`/sites/${filesPath}/files`] = options.baseUrl; | ||
} | ||
if (this.options.proxy) { | ||
if (Array.isArray(this.options.proxy)) { | ||
this.options.proxy = [ | ||
...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`), | ||
...this.options.proxy | ||
]; | ||
} else { | ||
this.options.proxy = { | ||
...proxies, | ||
...this.options.proxy | ||
}; | ||
} | ||
} else { | ||
this.options.proxy = proxies; | ||
} | ||
this.addModule("@nuxtjs/proxy"); | ||
} | ||
this.nuxt.hook("components:dirs", (dirs) => { | ||
@@ -54,3 +81,6 @@ dirs.push({ path: path.join(__dirname, "components") }); | ||
} | ||
let axiosSettings = { baseURL: baseUrl }; | ||
let axiosSettings = {}; | ||
if (baseUrl && !(options.proxy || {}).api) { | ||
axiosSettings.baseURL = baseUrl; | ||
} | ||
if (typeof options.axios === "object") { | ||
@@ -155,6 +185,10 @@ axiosSettings = Object.assign(axiosSettings, options.axios); | ||
} | ||
const index = await this.axios.get(this.options.endpoint); | ||
this.index = index.data.links; | ||
if (this.index[this.options.jsonapiResourceConfig]) { | ||
const resources = await this.axios.get(this.index[this.options.jsonapiResourceConfig].href); | ||
let index = ((await this.axios.get(this.options.endpoint) || {}).data || {}).links; | ||
const baseUrl = this.options.baseUrl; | ||
index = Object.fromEntries(Object.entries(index).map(([key, value]) => { | ||
value.href = value.href.replace(baseUrl, ""); | ||
return [key, value]; | ||
})); | ||
if (index[this.options.jsonapiResourceConfig]) { | ||
const resources = await this.axios.get(index[this.options.jsonapiResourceConfig].href); | ||
for (const resourceType in resources.data.data) { | ||
@@ -170,10 +204,12 @@ const resource2 = resources.data.data[resourceType]; | ||
const id = [item.entityType, item.bundle].join("--"); | ||
this.index[id] = { | ||
index[id] = { | ||
...item, | ||
...this.index[id] | ||
...index[id] | ||
}; | ||
} | ||
} | ||
this.index = index; | ||
if (resource) { | ||
return this.index[resource] ? this.index[resource] : false; | ||
const response = this.index[resource] ? this.index[resource] : false; | ||
return response; | ||
} | ||
@@ -180,0 +216,0 @@ return this.index; |
{ | ||
"name": "druxt", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "The Fully Decoupled Drupal Framework for Nuxt.js.", | ||
@@ -40,2 +40,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@nuxtjs/proxy": "^2.1.0", | ||
"axios": "^0.21.1", | ||
@@ -42,0 +43,0 @@ "chalk": "^4.1.2", |
import { DruxtClient } from 'druxt' | ||
export default (context, inject) => { | ||
const options = <%= devalue(options) %> | ||
const options = <%= JSON.stringify(options) %> | ||
// Disable the proxy for server side requests. | ||
if (!process.client && (options.proxy || {}).api) { | ||
options.proxy.api = false | ||
} | ||
const druxt = new DruxtClient(options.baseUrl, options) | ||
@@ -7,0 +12,0 @@ druxt.settings = options |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60457
911
11
+ Added@nuxtjs/proxy@^2.1.0
+ Added@nuxtjs/proxy@2.1.0(transitive)
+ Added@types/http-proxy@1.17.15(transitive)
+ Added@types/node@22.7.4(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedeventemitter3@4.0.7(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedhttp-proxy@1.18.1(transitive)
+ Addedhttp-proxy-middleware@1.3.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-plain-obj@3.0.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedundici-types@6.19.8(transitive)