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

@resourcefulhumans/rheactor-image-service

v3.1.0

Published

An image processing backend running on AWS Lambda.

Downloads

1

Readme

rheactor-image-service

npm version Build Status monitored by greenkeeper.io js-standard-style semantic-release Test Coverage Code Climate

An image processing backend running on AWS Lambda.

Uses gm with GraphicsMagick (which is available by default) on AWS lambda.

It takes JPEG or PNG images that are uploaded base64 encoded, crops and resizes them on the fly to 256x256px size, and stores them on an S3 bucket.

| Original | Result | |:--------:|:-------:| | Original | Result | | JPEG | JPEG | | 600x300 | 256x256 | | Original | Result | | PNG | JPEG | | 600x300 | 256x256 | | Original | Result | | JPEG | JPEG | | 300x600 | 256x256 |

Request

Users need to provide an JsonWebToken which is checked against the configured public key.

POST /upload
Content-Type: application/vnd.resourceful-humans.rheactor-image-service.v1+json
Authorization: Bearer <token>

{
  "$context":"https://github.com/ResourcefulHumans/rheactor-image-service#Upload",
  "image":"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
  "mimeType":"image/png"
}

Response

Content-Type: application/vnd.resourceful-humans.rheactor-image-service.v1+json

{
  "$context":"https://github.com/ResourcefulHumans/rheactor-image-service#UploadResult",
  "url":"https://s3.eu-central-1.amazonaws.com/rheactor-image-service/example.com/33f24f55-e435-4198-a148-fdd1095ffa96-user-5.jpg",
  "mimeType":"image/jpeg"
}

This implementation expects token's sub to be an URL, which will be used to prefix and suffix URLs. A sub value of https://example.com/user/5 was used in the example above.

Configuration

These environment variables need to be set on the lambda function:

  • S3_BUCKET
    Name of the S3 bucket, e.g. rheactor-image-service to where files are uploaded.
  • S3_REGION
    Region to use.
  • MOUNT_URL
    Public endpoint for the lamba function (as provided by API Gateway)
  • WEB_LOCATION
    Public URL for the bucket
  • PUBLIC_KEY_FILE
    Public key file in the bucket to be used for verifying tokens

Setup

npm install

# Configure these environment variables
AWS_ROLE=…
AWS_ACCESS_KEY_ID=…
AWS_SECRET_ACCESS_KEY=…
AWS_REGION=…
AWS_FUNCTION_NAME=…
NODE_ENV=…
VERSION=…

# install this as a new lambda function
make install

Local testing

For local testing use AWS SAM CLI. It has docker as a dependency. To start local testing run sam local start-api command. It will read template.yml and create local container with built function. It is required to build the project first - all files must be in build folder.

Because lambda function is not setting any additional CORS headers, easiest way is to use nginx to append them. Config for that is included in repo.