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

painless-image-upload

v0.0.5

Published

Easy to use image upload route, just mount it to your express application ๐Ÿ™Œ!

Downloads

3

Readme

painless-image-upload

Easy to use yet highly customizable image upload route, just mount it to your express application ๐Ÿ™Œ!

Quick Start

$ npm install --save painless-image-upload
$ mkdir images # Default image upload folder, you can configure this later.
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const painless = require('painless-image-upload');
app.use(bodyParser.json());

app.use('/painless', painless.router);

// ๐Ÿ™Œ Horray! You now have an image upload endpoint.

Usage

Now you can simply POST { "base64": YOUR BASE 64 IMAGE } to /painless/upload.

It will return something like the following:

{
    "100": "af09af68-c305-40f3-b954-b06958d737aa-100.png",
    "500": "af09af68-c305-40f3-b954-b06958d737aa-500.png",
    "1000": "af09af68-c305-40f3-b954-b06958d737aa-1000.png"
}

Configurations

To modify configurations, use painless.config variable.

imageIdGenerator: () => string

A function used to generate image ID, by default it simply returns uuid-v4. You can customize this anyway you like, as long as every ID is unique.

bodyNormalizer: (body) => { base64: string }

Takes in express req.body, and normalizes it to {base64: string} format.

By default it simply returns req.body.

For example, if you wish user to pass the base64 string in image field. You would make bodyNormalizer the following:

painless.config.bodyNormalizer = function(body) {
    return {
        base64: body.image,
    }
}

pathBuilder: (imageName: string) => string

Takes in the image file name, returns its real path, by default, this function just returns the imageName.

sizes: number[]

List of sizes you wish to save, default values are 100, 500 and 1000.

outputPath: string

Output directory for all images, default ./images.