Skip to content

Commit

Permalink
% eslint --fix index.js
Browse files Browse the repository at this point in the history
Fix this errors

```
/Users/argerich/dev/serverless-image-resizer/index.js
   2:17  error  Absolute imports should come before relative imports  import/first
   8:17  error  'sourceImage' was used before it was defined          no-use-before-define
  11:34  error  'successResponse' was used before it was defined      no-use-before-define
  31:7   error  'isS3Event' was used before it was defined            no-use-before-define
  37:7   error  'isApiGatewayEvent' was used before it was defined    no-use-before-define

✖ 5 problems (5 errors, 0 warnings)
```
  • Loading branch information
mgi166 committed Dec 23, 2017
1 parent e102a37 commit add070f
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ export const handle = (event, context, callback) => {

const image = sourceImage(event);

imageResizer({sourceBucket: image.bucket, sourceKey: image.key, options: image.options})
imageResizer({ sourceBucket: image.bucket, sourceKey: image.key, options: image.options })
.then(data => callback(null, successResponse(data)))
.catch(err => callback(err));
};

const successResponse = (data) => {
const successResponse = data =>
// NOTE: lambda proxy integration format
return {
isBase64Encoded: false,
statusCode: 201,
headers: {
"Content-Type": 'application/json'
},
body: JSON.stringify(data),
};
};
({
isBase64Encoded: false,
statusCode: 201,
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});

const sourceImage = (event) => {
let bucket = '';
Expand All @@ -38,21 +37,17 @@ const sourceImage = (event) => {
if (isApiGatewayEvent(event)) {
const u = url.parse(event.queryStringParameters.source_url);
bucket = u.hostname;
key = u.path.replace(/^\//, "");
key = u.path.replace(/^\//, '');
options = {
resizeOption: event.queryStringParameters.resize_option,
destS3Bucket: event.queryStringParameters.dest_s3_bucket,
destS3Prefix: event.queryStringParameters.dest_s3_prefix,
};
}

return { bucket: bucket, key: key, options: options };
return { bucket, key, options };
};

const isS3Event = (event) => {
return typeof event.Records === 'object';
};
const isS3Event = event => typeof event.Records === 'object';

const isApiGatewayEvent = (event) => {
return typeof event.Records === 'undefined';
};
const isApiGatewayEvent = event => typeof event.Records === 'undefined';

0 comments on commit add070f

Please sign in to comment.