How to use woden - 1 common examples

To help you get started, we’ve selected a few woden 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 jlfwong / 1rt / src / server.js View on Github external
res.status(500).end(error.stack + epilogue);
      });
  }
});

if (config.port) {
  http.createServer(app).listen(config.port, (err) => {
    if (err) {
      console.error(err);
    } else {
      console.log(`Express server listening on port ${config.port}`);
    }
  });

  // Cache thumbnail responses from YouTube in memory.
  const woden = new Woden({});
  woden.when(/i.ytimg.com/, {
    cacheTimeout: function(cacheEntry, req, proxyRes) {
      if (cacheEntry.body.length > (30 * 1024)) {
        return -1;  // don't cache large responses
      }

      if (proxyRes.statusCode !== 200) {
        return -1;  // only cache successful responses
      }

      const minutesToCache = 10;
      return minutesToCache * 60 * 1000;
    }
  });
  woden.listen(config.youtubeProxyPort, (err) => {
    if (err) {

woden

A small, simple proxy server module with some nice controls for caching.

MIT
Latest version published 3 years ago

Package Health Score

46 / 100
Full package analysis

Popular woden functions