@nuxtjs/strapi
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -5,2 +5,14 @@ # Changelog | ||
### [0.1.5](https://github.com/nuxt-community/strapi-module/compare/v0.1.4...v0.1.5) (2020-08-21) | ||
### Features | ||
* handle single-type entity type ([#35](https://github.com/nuxt-community/strapi-module/issues/35)) ([04b440b](https://github.com/nuxt-community/strapi-module/commit/04b440b105ecb63932d98d5e3a64fd265919353b)) | ||
### Bug Fixes | ||
* **plugin:** reactivity on hydatation ([#34](https://github.com/nuxt-community/strapi-module/issues/34)) ([b7e764f](https://github.com/nuxt-community/strapi-module/commit/b7e764f50f70ad68012fcc4a6f8d769f6ae27b67)) | ||
### [0.1.4](https://github.com/nuxt-community/strapi-module/compare/v0.1.3...v0.1.4) (2020-08-18) | ||
@@ -7,0 +19,0 @@ |
@@ -17,3 +17,3 @@ import Vue from 'vue' | ||
this.$http = ctx.$http.create({}) | ||
this.$http.setToken(this.getToken (), 'Bearer') | ||
this.$http.setToken(this.getToken(), 'Bearer') | ||
this.$http.setBaseURL(runtimeConfig.url || '<%= options.url %>') | ||
@@ -122,10 +122,17 @@ this.$http.onError((err) => { | ||
update (entity, id, data) { | ||
return this.$http.$put(`/${entity}/${id}`, data) | ||
if (typeof id === 'object') { | ||
data = id | ||
id = undefined | ||
} | ||
const path = [entity, id].filter(Boolean).join('/') | ||
return this.$http.$put(`/${path}`, data) | ||
} | ||
delete (entity, id) { | ||
return this.$http.$delete(`/${entity}/${id}`) | ||
const path = [entity, id].filter(Boolean).join('/') | ||
return this.$http.$delete(`/${path}`) | ||
} | ||
async graphql(data) { | ||
async graphql (data) { | ||
const request = await this.$http.$post(`/graphql`, data) | ||
@@ -152,13 +159,33 @@ return request.data; | ||
<%= JSON.stringify(options.entities) %>.forEach((entity) => { | ||
const key = `$${entity}` | ||
if (Strapi.prototype.hasOwnProperty(key)) { | ||
return | ||
} | ||
Object.defineProperty(Strapi.prototype, key, { | ||
get () { | ||
const that = this | ||
return { | ||
let key | ||
let type = 'collection' | ||
if (typeof entity === 'object') { | ||
key = `$${entity.name}` | ||
type = entity.type || 'collection' | ||
entity = entity.name | ||
} else { | ||
key = `$${entity}` | ||
} | ||
if (Strapi.prototype.hasOwnProperty(key)) { | ||
return | ||
} | ||
Object.defineProperty(Strapi.prototype, key, { | ||
get () { | ||
const that = this | ||
return ({ | ||
single: { | ||
find (...args) { | ||
return that.find(entity, ...args) | ||
}, | ||
update (...args) { | ||
return that.update(entity, ...args) | ||
}, | ||
delete (...args) { | ||
return that.delete(entity, ...args) | ||
} | ||
}, | ||
collection: { | ||
find (...args) { | ||
return that.find(entity, ...args) | ||
}, | ||
findOne (...args) { | ||
@@ -180,5 +207,6 @@ return that.findOne(entity, ...args) | ||
} | ||
} | ||
}) | ||
})[type] | ||
} | ||
}) | ||
}) | ||
@@ -199,3 +227,3 @@ const strapi = new Strapi(ctx) | ||
if (process.client && nuxtState.strapi) { | ||
strapi.state = nuxtState.strapi | ||
strapi.state = Vue.observable(nuxtState.strapi) | ||
} | ||
@@ -202,0 +230,0 @@ |
{ | ||
"name": "@nuxtjs/strapi", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Strapi module for NuxtJS", | ||
@@ -25,3 +25,3 @@ "repository": "nuxt-community/strapi-module", | ||
"dependencies": { | ||
"@nuxt/http": "^0.5.10", | ||
"@nuxt/http": "^0.5.11", | ||
"cookie-universal-nuxt": "^2.1.4", | ||
@@ -28,0 +28,0 @@ "defu": "^3.1.0", |
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
12789
219
Updated@nuxt/http@^0.5.11