New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rehost

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehost

Express middleware to rehost and resize images

latest
Source
npmnpm
Version
0.1.0-beta
Version published
Maintainers
1
Created
Source

README

Express middleware to rehost and resize images

Install

$ npm install rehost

Usage

var express = require('express');
var rehost = require('rehost');
var app = express();
app.use('/:rehost.:format', rehost());
app.listen(3000);

Requesting the following URL on the server:

http://localhost:3000/aHR0cDovL2V4YW1wbGUuY29tL2ltYWdlLnBuZw.jpg?resize=500x500

Will fetch, resize and convert the image at:

http://example.com/image.png

The source URL is encoded using "Base 64 Encoding with URL and Filename Safe Alphabet" from RFC 4648 without padding.

Example in JavaScript:

var base64 = require('base64-url');
var url = 'http://example.com/image.jpg'
var enc = base64.encode(url);

Example in Ruby:

require 'base64'
url = 'http://example.com/image.jpg'
enc = Base64.urlsafe_encode64(url, padding: false)

Parameters

The resize parameter is a subset of ImageMagick geometry: <width>x<height>{!}.

The format parameter to convert the image can be jpg or png.

The rehost, resize and format parameters can be in the query string or the path of the request. They can also be defined in an optional options object passed to the middleware function.

Caching

No caching is done on the server so it should be running behind a CDN.

License

Copyright (c) 2017 Vincent Ollivier. Released under MIT.

FAQs

Package last updated on 20 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts