0.4.2 • Published 5 years ago

lambda-images-resizer v0.4.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Images resizing with AWS Lambda

npm npm David

Install

yarn add lambda-images-resizer

Example of index.js file of lambda function

const HttpError = require('lambda-images-resizer').HttpError
const createProcessor = new require('lambda-images-resizer')
const processor = createProcessor({
  region: process.env.REGION,
  bucket: process.env.BUCKET,
  cachePrefix: process.env.CACHE_PREFIX,
  signatureVerification: process.env.SIGNATURE_VERIFICATION === '1',
  signatureSecret: process.env.SIGNATURE_SECRET,
  cdnUrl: process.env.CDN_URL,
  maxWidth: parseInt(process.env.MAX_WIDTH, 10) || 1920,
  maxHeight: parseInt(process.env.MAX_HEIGHT, 10) || 1080,
  logging: process.env.LOGGING === '1'
})

const handler = function(event, context) {
  processor(event)
    .then((response) => {
      context.succeed(response)
    })
    .catch((err) => {
      if (err instanceof HttpError) {
        return context.succeed({
          statusCode: err.statusCode,
          body: err.message
        })
      }
      return context.fail(err)
    })
}

exports.handler = handler

To-do list:

  • Resizing constraints
  • Signatures checking
0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.1.5

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago