New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dewib/xhr-cache

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dewib/xhr-cache - npm Package Compare versions

Comparing version 3.2.1 to 3.2.2

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [3.2.2](https://github.com/gaetansenn/xhr-cache/compare/v3.2.1...v3.2.2) (2021-03-11)
### Bug Fixes
* fix resources injection to plugin and fix tests ([f6dfde6](https://github.com/gaetansenn/xhr-cache/commit/f6dfde61bd082ca50ccf93bb47c74e3a56fc505a))
### [3.2.1](https://github.com/gaetansenn/xhr-cache/compare/v3.2.0...v3.2.1) (2021-03-11)

@@ -7,0 +14,0 @@

90

lib/module.js

@@ -210,3 +210,4 @@ import { join, resolve } from 'path'

module.exports = async function xhrCache () {
// Set default path into static directory
const buildProcess = this.options._build !== undefined && this.options.dev === false
// Set default path into static directory
defaultsConfig.path = join(this.nuxt.options.srcDir, defaultsConfig.rootFolder)

@@ -216,27 +217,2 @@

// Inject plugin
this.addPlugin({
src: resolve(__dirname, 'plugin.js'),
fileName: 'xhr-cache/plugin.js',
options: {
config: JSON.stringify({
rootUrl: conf.rootUrl,
rootFolder: conf.rootFolder,
serverUrl: conf.serverUrl
}),
resources: JSON.stringify(resources.map(resource => ({
id: resource.id
})))
}
})
// Extend xhrCache with plugins
if (conf.plugins) {
conf.plugins.forEach(p => this.options.plugins.push(p))
delete conf.plugins
}
// Skip server middleware injection during build
if (this.options._build !== undefined && this.options.dev === false) { return false }
conf.serverUrl = `http${this.options.server.https ? 's' : ''}://${this.options.server.host}:${this.options.server.port}`

@@ -247,6 +223,6 @@

/* eslint-disable-next-line */
console.info(`${libPrefix} Register apiKey ${conf.apiKey}`)
if (!buildProcess) console.info(`${libPrefix} Register apiKey ${conf.apiKey}`)
// Clean directory cache
if (conf.clean) { rimraf.sync(conf.path) }
if (!buildProcess && conf.clean) { rimraf.sync(conf.path) }

@@ -298,3 +274,3 @@ await Promise.all(conf.resources.map(async (resource) => {

// Init custom resource if provided
if (isFunction(resource.init)) { await resource.init(context) }
if (!buildProcess && isFunction(resource.init)) { await resource.init(context) }

@@ -316,5 +292,7 @@ const middleware = async (req, res, next) => {

/* eslint-disable-next-line */
if (!buildProcess) {
/* eslint-disable-next-line */
console.info(`${libPrefix} Serve custom '${resource.name}' resource to ${`${conf.serverUrl}/${join(path)}`}`)
this.addServerMiddleware(middleware)
this.addServerMiddleware(middleware)
}
} else {

@@ -327,3 +305,3 @@ // Bind default path to get and store method

// Inject default middleware
this.addServerMiddleware(defaultMiddleware(conf, resource, context))
if (!buildProcess) { this.addServerMiddleware(defaultMiddleware(conf, resource, context)) }

@@ -346,18 +324,42 @@ resources.push({

if (!buildProcess) {
// Inject resources list
this.addServerMiddleware(resourcesList(conf))
// Inject refresh middleware
this.addServerMiddleware(refreshMiddeware(conf))
// Inject resource route
this.addServerMiddleware(getResource(conf))
this.addServerMiddleware(resourcesList(conf))
// Inject refresh middleware
this.addServerMiddleware(refreshMiddeware(conf))
// Inject resource route
this.addServerMiddleware(getResource(conf))
// Inject helper to requests
this.addServerMiddleware((req, res, next) => {
req.xhrCache = {
resources,
apiKey: conf.apiKey
// Inject helper to requests
this.addServerMiddleware((req, res, next) => {
req.xhrCache = {
resources,
apiKey: conf.apiKey
}
next()
})
}
// Inject plugin
this.addPlugin({
src: resolve(__dirname, 'plugin.js'),
fileName: 'xhr-cache/plugin.js',
options: {
config: JSON.stringify({
rootUrl: conf.rootUrl,
rootFolder: conf.rootFolder,
serverUrl: conf.serverUrl
}),
resources: JSON.stringify(resources.map(resource => ({
id: resource.id
})))
}
})
next()
})
// Extend xhrCache with plugins
if (conf.plugins) {
conf.plugins.forEach(p => this.options.plugins.push(p))
delete conf.plugins
}
}
{
"name": "@dewib/xhr-cache",
"version": "3.2.1",
"version": "3.2.2",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Cache api resources and serve it as static resource",

@@ -1,2 +0,2 @@

# XHR Cache Module v3.2.1
# XHR Cache Module v3.2.2

@@ -3,0 +3,0 @@ [![npm version][npm-version-src]][npm-version-href]

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