How to use the apicache.__mockMiddleware function in apicache

To help you get started, we’ve selected a few apicache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / pwa-buildpack / lib / Utilities / __tests__ / addImgOptMiddleware.spec.js View on Github external
jest.mock('redis', () => ({
    redisClient: jest.fn(() => 'redis client object')
}));
const { parse } = require('querystring');
const addImgOptMiddleware = require('../addImgOptMiddleware');
const expressSharp = require('@magento/express-sharp');
const apicache = require('apicache');
const redis = require('redis');

const mockSharpMiddleware = expressSharp.__mockMiddleware;
const mockCacheMiddleware = apicache.__mockMiddleware;

let app;
let config;
let filterMiddleware;
let req;
let res;

const next = () => {};

const testUrl = (url, method = 'GET') => {
    addImgOptMiddleware(app, config);
    const { pathname, search } = new URL(url, 'http://localhost');
    req = {
        method,
        path: pathname,
        query: parse(search.replace(/^\?/, '')),

apicache

An ultra-simplified API response caching middleware for Express/Node using plain-english durations.

MIT
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis