Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: swellstores/swell-node
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.2.0
Choose a base ref
...
head repository: swellstores/swell-node
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.3.0
Choose a head ref
  • 3 commits
  • 13 files changed
  • 2 contributors

Commits on Sep 14, 2023

  1. Fix: code cleanup and tests (#20)

    * code cleanup
    
    * require url
    
    * no mjml
    
    * code cleanup
    
    * fixed tests, rm sinon, ported mocks to jest
    
    * port chai assert -> jest expect
    
    * bump dependencies
    
    * renamed client.server -> client.connection
    
    * prettier code-style
    swellmike authored Sep 14, 2023
    Copy the full SHA
    68f20b2 View commit details

Commits on Sep 18, 2023

  1. Feature: Support no-cache requests (#21)

    * code cleanup
    
    * require url
    
    * no mjml
    
    * code cleanup
    
    * fixed tests, rm sinon, ported mocks to jest
    
    * port chai assert -> jest expect
    
    * bump dependencies
    
    * renamed client.server -> client.connection
    
    * prettier code-style
    
    * skip cache is $nocache is specified in requestData
    swellmike authored Sep 18, 2023
    Copy the full SHA
    b7dd15c View commit details
  2. 5.3.0

    swellmike committed Sep 18, 2023
    Copy the full SHA
    6b32c39 View commit details
7 changes: 1 addition & 6 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -3,12 +3,7 @@
"bracketSameLine": false,
"bracketSpacing": true,
"endOfLine": "lf",
"overrides": [
{
"files": "*.mjml",
"options": { "parser": "html" }
}
],
"overrides": [],
"printWidth": 80,
"semi": true,
"singleQuote": true,
23 changes: 16 additions & 7 deletions lib/cache/index.js
Original file line number Diff line number Diff line change
@@ -83,9 +83,9 @@ class Cache {

// Get path to a cache file
getPath(...args) {
const clientPart = `${this.params.path.replace(/\/$/, '')}/client.${this.params.clientId}${
this.env ? `_${this.env}` : ''
}`;
const clientPart = `${this.params.path.replace(/\/$/, '')}/client.${
this.params.clientId
}${this.env ? `_${this.env}` : ''}`;

const path = [clientPart, ...args].join('.');

@@ -135,7 +135,10 @@ class Cache {
const resultCollections = this.resultCollections(result);
for (const collection of resultCollections) {
// Collection may not be cacheable
if (cached[collection] === undefined && this.versions[collection] === undefined) {
if (
cached[collection] === undefined &&
this.versions[collection] === undefined
) {
continue;
}
this.putIndex(collection, cacheKey, size);
@@ -153,7 +156,9 @@ class Cache {

// Limit size of index per client/collection
if (this.indexes[collection] !== undefined) {
if (Object.keys(this.indexes[collection]).length >= this.params.indexLimit) {
if (
Object.keys(this.indexes[collection]).length >= this.params.indexLimit
) {
this.truncateIndex(collection);
}
}
@@ -212,7 +217,10 @@ class Cache {
const cachedCollections = Object.keys(result.$cached);
for (const collection of cachedCollections) {
const version = result.$cached[collection];
if (this.versions[collection] === undefined || version !== this.versions[collection]) {
if (
this.versions[collection] === undefined ||
version !== this.versions[collection]
) {
this.putVersion(collection, version);
invalid[collection] = true;
// Hack to make admin.settings affect other api.settings
@@ -295,7 +303,8 @@ class Cache {

// Get array of collections affected by a result
resultCollections(result) {
const collections = result.$collection !== undefined ? [result.$collection] : [];
const collections =
result.$collection !== undefined ? [result.$collection] : [];
// Combine $collection and $expanded headers
if (result.$expanded !== undefined) {
for (const expCollection of result.$expanded) {
Loading