0.5.0 • Published 3 years ago

@diagrams-ts/local-image-cache-plugin v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Image cache plugin

Downloads images for URLs and stores them in a cache inside the node_modules directory. Replaces the URL of the image with the local file. Makes it possible to create binary images, from nodes that include html paths.

For diagrams-ts we pull images from the diagramsrepository on Github, using requests without authentication. Github limits those requests to 60 requests/hour. In order to not hit the rate limit some form of caching needs to be done.

Installation and Requirements

This plugin only runs on node.

Install this package by running:

npm install @diagrams-ts/local-image-cache-plugin

# or when using yarn

yarn add @diagrams-ts/local-image-cache-plugin

Usage

You can add the plugin to the createDiagrams call, as a nodePluginparameter.

import * as diagrams from "diagrams-ts";
import { LocalImageCachePlugin } from "@diagrams-ts/local-image-cache-plugin";

const {
  providers: {
    aws: {
      compute: { Lambda },
      storage: { S3 },
    },
  },
  createDiagram,
  diagram,
} = diagrams;

const awsFlow = () => diagram`${Lambda("Lambda")}>>${S3("Bucket")}`;

(async () => {
  try {
    await createDiagram({
      label: "AWS Simple",
      filename: "./output/aws-simple.png",
      nodePlugins: [LocalImageCachePlugin],
    })(awsFlow());
  } catch (error) {
    console.log(error);
  }
})();

☝️ There is no need to do this, when running from node as diagrams-ts uses this plugin by default.

0.5.0

3 years ago

0.4.0

3 years ago

0.3.10

3 years ago

0.3.4

3 years ago

0.3.2

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago