npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@copicake/copicake-js

v0.0.8

Published

Copicake JS Library

Downloads

12

Readme

Copicake JS

🍰 Copicake, a data-driven image generating service to let you generate any social media material with just ONE CLICK.

  • 🔗 Website: https://copicake.com/
  • 📘 Official API Docs: https://docs.copicake.com/

Installations

For npm user

npm install --save @copicake/copicake-js

For yarn user

yarn add @copicake/copicake-js

Usage

Initialization

You need to initialize to get copicake instance first :

import Copicake from "@copicake/copicake-js";

const copicake = new Copicake({
  apiKey: "your-api-key",
});

Image

Create an image

create(data: Object)

copicake.image
  .create({
    template_id: "YOU_TEMPLATE_ID",
    changes: [
      { name: "text-9so09m", text: "hello world", fill: "#ff0000" },
      { name: "image-yeavh7", src: "https://your_website.com/test.png" },
    ],
    options: {
      webhook_url: "https://your_website.com/webhook_url",
    },
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.error(error);
  });

Get an image

get(renderingId: string)

const renderingId = `YOUR_RENDERING_ID`;

copicake.image
  .get(renderingId)
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.error(error);
  });

Get an image (long polling)

getUntilFinished(renderingId: string)

Sometimes you may notice that your image is still under processing state, this is because the image is still being processed in the background by our servers.

In this way, we provide another handy method called getUntilFinished() to get the image until the image is ready.

Internally, this is just a wrapper of get() method with built-in retry mechanism. If after MAX_RETRY_TIMES and the image is still under processing state, we will throw an error (500) to let you know.

const renderingId = `YOUR_RENDERING_ID`;

copicake.image
  .getUntilFinished(renderingId)
  .then((response) => {
    if (response.status === "success") {
      // do something
    } else if (response.status === "failed") {
      // do something
    }
  })
  .catch((error) => {
    console.error(error);
  });

Utils

Create a temporary image for later use

uploadTempImage(file: File | Buffer, type: "png" | "gif" | "jpg" | "jpeg")

If you don't have a server to host images, we provided a handy way to let you upload a temporary image to our s3 and you can use the returned URL for later use.

  1. File on Browser
  2. Buffer on Node.js

P.S. Every temporary image will be removed within 1 day to avoid abuse

copicake.utils
  .uploadTempImage(file, "png")
  .then((result) => {
    // result === https://s3.ap-northeast-1.amazonaws.com/copicake/temp/ak0zixy6rewsh6vaamzi.png
    console.log(result);
  })
  .catch((error) => {
    console.log(error);
  });