Skip to content

Commit

Permalink
Clean index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sagidM committed Mar 30, 2018
1 parent 8cb575a commit 4427142
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
const AWS = require('aws-sdk')
const S3 = new AWS.S3({signatureVersion: 'v4'});
const Sharp = require('sharp');
const Pattern = new RegExp("(.*/)?(.*)/(.*)");
const PathPattern = new RegExp("(.*/)?(.*)/(.*)");

// parameters
const BUCKET = process.env.BUCKET;
const URL = process.env.URL;
const {BUCKET, URL} = process.env


exports.handler = function(event, context, callback) {
exports.handler = function(event, _context, callback) {
var path = event.queryStringParameters.path;
var parts = Pattern.exec(path);
var parts = PathPattern.exec(path);
var dir = parts[1] || '';
var options = parts[2].split('_');
var filename = parts[3];
Expand All @@ -40,10 +39,10 @@ exports.handler = function(event, context, callback) {
callback(null, {
statusCode: 400,
body: `Unknown func parameter "${func}"\n` +
'For query ".../150x150_func", "_func" must be either empty or "_min" or "_max"',
'For query ".../150x150_func", "_func" must be either empty, "_min" or "_max"',
headers: {"Content-Type": "text/plain"}
})
return new Promise(() => {});
return new Promise(() => {}) // the next then-blocks will never be executed
}

return img.withoutEnlargement().toBuffer();
Expand Down

0 comments on commit 4427142

Please sign in to comment.