Socket
Socket
Sign inDemoInstall

druxt

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

druxt - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0

40

CHANGELOG.md
# 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 @@

52

dist/druxt.esm.js

@@ -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;

3

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc