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.

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 11 months ago

Package Health Score

70 / 100
Full package analysis

Similar packages