Skip to content

Commit bfd513f

Browse files
author
alfredbrockotter
committed
BREAKING CHANGE: upgraded kentico-cloud-js
2 parents 50b83df + c0ed363 commit bfd513f

File tree

7 files changed

+1741
-493
lines changed

7 files changed

+1741
-493
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ typings/
6363
# dotenv environment variables file
6464
.env
6565

66+
# visual studio 2019
67+
.vs
68+
6669
#custom
6770
coverage
6871
dist

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ npm i rxjs --save (because this is a peer dependency of the Kentico Cloud Delive
3535
projectId: 'xxxx-xxx-xxxx-xxxx-xxxxx',
3636
enableAdvancedLogging: false,
3737
previewApiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
38-
enablePreviewMode: true
38+
enablePreviewMode: true,
39+
baseUrl: 'https://custom.uri/api/KenticoCloudProxy',
40+
securedApiKey: 'xxx',
41+
enableSecuredMode: true
3942
},
4043
```
4144
- $deliveryClient is now globally available.
@@ -44,12 +47,12 @@ npm i rxjs --save (because this is a peer dependency of the Kentico Cloud Delive
4447

4548
this.$deliveryClient.items()
4649
.type('page')
47-
.getPromise()
50+
.toPromise()
4851
.then(response => console.log('DeliveryClient Response', response));
4952

5053
```
5154
## Note:
52-
By default Nuxt can only work with promises. Therefor you always use the "getPromise" method provided by the Kentico Cloud Delivery SDK! RxJs operator's are not supported at the moment.
55+
By default Nuxt can only work with promises. Therefor you always use the "toPromise" method provided by the Kentico Cloud Delivery SDK! RxJs operator's are not supported at the moment.
5356

5457
## Caching
5558
API calls can be "cached" (they will be stored in memory) client side via the "viaCache" method.
@@ -62,3 +65,30 @@ API calls can be "cached" (they will be stored in memory) client side via the "v
6265

6366
```
6467

68+
## Extending
69+
70+
If you need to customize the Kentico Cloud Delivery SDK by registering interceptors and changing global config, you have to create a nuxt plugin.
71+
72+
### nuxt.config.js
73+
```
74+
{
75+
modules: [
76+
'kenticocloud-nuxt-module',
77+
],
78+
79+
plugins: [
80+
'~/plugins/kenticocloudNuxtModule'
81+
]
82+
}
83+
```
84+
85+
### plugins/kenticocloudNuxtModule.js
86+
```
87+
export default function ({ store, $deliveryClient }) {
88+
$deliveryClient.config.globalHeaders = (queryConfig) => {
89+
let headers = [];
90+
headers.push({header: 'Authorization', value: 'bearer ' + store.state.token });
91+
return headers;
92+
}
93+
}
94+
```

lib/module.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const path = require('path');
22

33
module.exports = function kenticocloud (moduleOptions) {
4-
console.log('moduleOptions', moduleOptions);
5-
// Merge options
64
const options = Object.assign({
75
projectId: process.env.KENTICOCLOUD_PROJECTID || '',
86
previewApiKey: process.env.KENTICOCLOUD_PREVIEWAPIKEY || null,

lib/services/CacheService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class CacheService {
99
viaCache(query, seconds, cacheKey, isServerProcess) {
1010
// Always perform a query when on the server
1111
if (this.cacheEntries && query && isServerProcess) {
12-
return query.getPromise();
12+
return query.toPromise();
1313
};
1414

1515
if (!seconds) {
@@ -28,7 +28,7 @@ export default class CacheService {
2828
});
2929
}
3030
else {
31-
return query.getPromise().then(response => {
31+
return query.toPromise().then(response => {
3232
if (cacheEntry) {
3333
cacheEntry.timestamp = new Date();
3434
}

package.json

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"test": "mocha tests/*.js --require @babel/register --reporter spec || exit 0",
1414
"posttest": "eslint lib tests"
1515
},
16+
"release": {
17+
"branch": "master"
18+
},
19+
"publishConfig": {
20+
"registry": "https://registry.npmjs.org/"
21+
},
1622
"eslintIgnore": [
1723
"lib/templates/*.*"
1824
],
@@ -43,30 +49,31 @@
4349
},
4450
"homepage": "https://github.com/Domitnator/kenticocloud-nuxt-module#readme",
4551
"dependencies": {
46-
"kentico-cloud-delivery": "^5.7.2"
52+
"kentico-cloud-delivery": "^6.2.0"
4753
},
4854
"devDependencies": {
49-
"@babel/core": "^7.3.4",
50-
"@babel/preset-env": "^7.3.4",
51-
"@babel/register": "^7.0.0",
55+
"@babel/core": "^7.5.5",
56+
"@babel/preset-env": "^7.5.5",
57+
"@babel/register": "^7.4.4",
58+
"@semantic-release/npm": "^5.1.15",
5259
"babel-plugin-syntax-async-functions": "^6.13.0",
5360
"babel-plugin-transform-regenerator": "^6.26.0",
5461
"babel-polyfill": "^6.26.0",
5562
"chai": "^4.2.0",
5663
"chai-as-promised": "^7.1.1",
57-
"eslint": "^5.14.1",
64+
"eslint": "^5.16.0",
5865
"eslint-config-standard": "^12.0.0",
59-
"eslint-plugin-import": "^2.16.0",
66+
"eslint-plugin-import": "^2.18.2",
6067
"eslint-plugin-node": "^8.0.1",
61-
"eslint-plugin-promise": "^4.0.1",
62-
"eslint-plugin-standard": "^4.0.0",
68+
"eslint-plugin-promise": "^4.2.1",
69+
"eslint-plugin-standard": "^4.0.1",
6370
"mocha": "^5.2.0",
64-
"rollup": "^1.3.1",
65-
"rollup-plugin-babel": "^4.3.2",
66-
"rollup-plugin-commonjs": "^9.2.1",
67-
"rollup-plugin-json": "^3.1.0",
68-
"rollup-plugin-node-resolve": "^4.0.1",
69-
"rollup-plugin-replace": "^2.1.0",
70-
"semantic-release": "^15.13.3"
71+
"rollup": "^1.15.3",
72+
"rollup-plugin-babel": "^4.3.3",
73+
"rollup-plugin-commonjs": "^10.1.0",
74+
"rollup-plugin-json": "^4.0.0",
75+
"rollup-plugin-node-resolve": "^5.2.0",
76+
"rollup-plugin-replace": "^2.2.0",
77+
"semantic-release": "^15.13.24"
7178
}
7279
}

tests/cacheService.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ should();
88
chai.use(chaiAsPromised);
99

1010
const query = {
11-
getPromise: () => {
11+
toPromise: () => {
1212
return new Promise(function (resolve, reject) {
1313
resolve('fake data');
1414
});
@@ -40,7 +40,7 @@ describe('Test the behavior of the CacheService', function () {
4040
expect(s).to.equal(null);
4141
});
4242
});
43-
it('viaCache method returns response from \'getPromise\'', () => {
43+
it('viaCache method returns response from \'toPromise\'', () => {
4444
let service = new CacheService([]);
4545

4646
return service.viaCache(query, 10, 'key1', false).then(s => {

0 commit comments

Comments
 (0)