Skip to content

Commit

Permalink
Merge branch 'yarn-upgrade-eslint'
Browse files Browse the repository at this point in the history
  • Loading branch information
mgi166 committed Dec 23, 2017
2 parents 81609d2 + 36d278b commit 6d2c1cd
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "airbnb-base",
"extends": ["airbnb-base", "eslint:recommended"],
"rules": {
"no-console": "off",
"import/prefer-default-export": "off"
Expand Down
54 changes: 24 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
import imageResizer from './src/imageResizer';
import url from 'url';
import imageResizer from './src/imageResizer';

export const handle = (event, context, callback) => {
console.log('eventObject: %s', JSON.stringify(event, null, 2));
console.log('context: %s', JSON.stringify(context, null, 2));

const image = sourceImage(event);

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

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

const sourceImage = (event) => {
let bucket = '';
Expand All @@ -38,21 +18,35 @@ 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 successResponse = data =>
// NOTE: lambda proxy integration format
({
isBase64Encoded: false,
statusCode: 201,
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});

export const handle = (event, context, callback) => {
console.log('eventObject: %s', JSON.stringify(event, null, 2));
console.log('context: %s', JSON.stringify(context, null, 2));

const image = sourceImage(event);

const isApiGatewayEvent = (event) => {
return typeof event.Records === 'undefined';
imageResizer({ sourceBucket: image.bucket, sourceKey: image.key, options: image.options })
.then(data => callback(null, successResponse(data)))
.catch(err => callback(err));
};
4 changes: 2 additions & 2 deletions src/imageResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const resizeImage = (imagePath, info, options) =>
new Promise((resolve, reject) => {
console.log('resizeImage start...');
const resizeOpts = /^(\d+)x(\d+)([%@!<>])?$/g.exec(
options.resizeOption || process.env.RESIZE_OPTION
options.resizeOption || process.env.RESIZE_OPTION,
);

gm(imagePath)
Expand All @@ -64,7 +64,7 @@ const uploadImage = (buffer, info, options) =>
})
;

export default async ({sourceBucket, sourceKey, options}) => {
export default async ({ sourceBucket, sourceKey, options }) => {
const imagePath = await downloadImage({
Bucket: sourceBucket,
Key: sourceKey,
Expand Down
124 changes: 74 additions & 50 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ acorn@^4.0.3:
version "4.0.13"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787"

acorn@^5.0.0, acorn@^5.1.1:
acorn@^5.0.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.1.tgz#53fe161111f912ab999ee887a90a0bc52822fd75"

acorn@^5.2.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7"

agent-base@2:
version "2.1.1"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-2.1.1.tgz#d6de10d5af6132d5bd692427d46fc538539094c7"
Expand Down Expand Up @@ -283,7 +287,15 @@ aws4@^1.2.1:
version "1.6.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"

babel-code-frame@^6.16.0, babel-code-frame@^6.22.0:
babel-code-frame@^6.16.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
dependencies:
chalk "^1.1.3"
esutils "^2.0.2"
js-tokens "^3.0.2"

babel-code-frame@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4"
dependencies:
Expand Down Expand Up @@ -1055,8 +1067,8 @@ cli-cursor@^1.0.1:
restore-cursor "^1.0.1"

cli-width@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.1.0.tgz#b234ca209b29ef66fc518d9b98d5847b00edf00a"
version "2.2.0"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"

cliui@^2.1.0:
version "2.1.0"
Expand Down Expand Up @@ -1286,7 +1298,7 @@ date-now@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"

debug@2, [email protected], debug@^2.2.0, debug@^2.6.8:
debug@2, [email protected], debug@^2.2.0:
version "2.6.8"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc"
dependencies:
Expand All @@ -1298,7 +1310,13 @@ [email protected]:
dependencies:
ms "2.0.0"

debug@^2.1.1, debug@~2.2.0:
debug@^2.1.1, debug@^2.6.8:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"

debug@~2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da"
dependencies:
Expand Down Expand Up @@ -1426,11 +1444,10 @@ [email protected]:
isarray "^1.0.0"

doctrine@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63"
version "2.0.2"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.2.tgz#68f96ce8efc56cc42651f1faadb4f175273b0075"
dependencies:
esutils "^2.0.2"
isarray "^1.0.0"

dom-walk@^0.1.0:
version "0.1.1"
Expand Down Expand Up @@ -1519,20 +1536,20 @@ error-ex@^1.2.0:
dependencies:
is-arrayish "^0.2.1"

es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14:
version "0.10.26"
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.26.tgz#51b2128a531b70c4f6764093a73cbebb82186372"
es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14:
version "0.10.37"
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.37.tgz#0ee741d148b80069ba27d020393756af257defc3"
dependencies:
es6-iterator "2"
es6-symbol "~3.1"
es6-iterator "~2.0.1"
es6-symbol "~3.1.1"

es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.1.tgz#8e319c9f0453bf575d374940a655920e59ca5512"
es6-iterator@^2.0.1, es6-iterator@~2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7"
dependencies:
d "1"
es5-ext "^0.10.14"
es6-symbol "^3.1"
es5-ext "^0.10.35"
es6-symbol "^3.1.1"

es6-map@^0.1.3:
version "0.1.5"
Expand All @@ -1555,7 +1572,7 @@ es6-set@~0.1.5:
es6-symbol "3.1.1"
event-emitter "~0.3.5"

[email protected], es6-symbol@^3.1, es6-symbol@^3.1.1, es6-symbol@~3.1, es6-symbol@~3.1.1:
[email protected], es6-symbol@^3.1.1, es6-symbol@~3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77"
dependencies:
Expand Down Expand Up @@ -1607,8 +1624,8 @@ eslint-module-utils@^2.1.1:
pkg-dir "^1.0.0"

eslint-plugin-import@^2.2.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.7.0.tgz#21de33380b9efb55f5ef6d2e210ec0e07e7fa69f"
version "2.8.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz#fa1b6ef31fcb3c501c09859c1b86f1fc5b986894"
dependencies:
builtin-modules "^1.1.1"
contains-path "^0.1.0"
Expand Down Expand Up @@ -1662,10 +1679,10 @@ eslint@^3.9.1:
user-home "^2.0.0"

espree@^3.4.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.0.tgz#98358625bdd055861ea27e2867ea729faf463d8d"
version "3.5.2"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca"
dependencies:
acorn "^5.1.1"
acorn "^5.2.1"
acorn-jsx "^3.0.0"

esprima@^4.0.0:
Expand Down Expand Up @@ -1881,8 +1898,8 @@ find-up@^2.0.0:
locate-path "^2.0.0"

flat-cache@^1.2.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96"
version "1.3.0"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481"
dependencies:
circular-json "^0.3.1"
del "^2.0.2"
Expand Down Expand Up @@ -1970,8 +1987,8 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2:
rimraf "2"

function-bind@^1.0.2:
version "1.1.0"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"

gauge@~1.2.5:
version "1.2.7"
Expand Down Expand Up @@ -2274,8 +2291,8 @@ ieee754@^1.1.4:
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"

ignore@^3.2.0:
version "3.3.3"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.3.tgz#432352e57accd87ab3110e82d3fea0e47812156d"
version "3.3.7"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021"

imurmurhash@^0.1.4:
version "0.1.4"
Expand Down Expand Up @@ -2342,8 +2359,8 @@ inquirer@^1.0.2:
through "^2.3.6"

interpret@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90"
version "1.1.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"

invariant@^2.2.0:
version "2.2.2"
Expand Down Expand Up @@ -2420,8 +2437,8 @@ is-glob@^2.0.0, is-glob@^2.0.1:
is-extglob "^1.0.0"

is-my-json-valid@^2.10.0:
version "2.16.0"
resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz#f079dd9bfdae65ee2038aae8acbc86ab109e3693"
version "2.17.1"
resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz#3da98914a70a22f0a8563ef1511a246c6fc55471"
dependencies:
generate-function "^2.0.0"
generate-object-property "^1.1.0"
Expand Down Expand Up @@ -2459,8 +2476,8 @@ is-path-in-cwd@^1.0.0:
is-path-inside "^1.0.0"

is-path-inside@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.0.tgz#fc06e5a1683fbda13de667aff717bbc10a48f37f"
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036"
dependencies:
path-is-inside "^1.0.1"

Expand All @@ -2485,10 +2502,8 @@ is-redirect@^1.0.0:
resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24"

is-resolvable@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62"
dependencies:
tryit "^1.0.1"
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.1.tgz#acca1cd36dbe44b974b924321555a70ba03b1cf4"

is-retry-allowed@^1.0.0:
version "1.1.0"
Expand Down Expand Up @@ -2543,11 +2558,18 @@ [email protected]:
version "0.15.0"
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217"

js-tokens@^3.0.0:
js-tokens@^3.0.0, js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"

js-yaml@^3.5.1, js-yaml@^3.6.1, js-yaml@^3.8.3:
js-yaml@^3.5.1:
version "3.10.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc"
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"

js-yaml@^3.6.1, js-yaml@^3.8.3:
version "3.9.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.9.1.tgz#08775cebdfdd359209f0d2acd383c8f86a6904a0"
dependencies:
Expand Down Expand Up @@ -3541,8 +3563,8 @@ resolve-from@^1.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"

resolve@^1.1.6, resolve@^1.2.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.4.0.tgz#a75be01c53da25d934a98ebd0e4c4a7312f92a86"
version "1.5.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"
dependencies:
path-parse "^1.0.5"

Expand All @@ -3559,12 +3581,18 @@ right-align@^0.1.1:
dependencies:
align-text "^0.1.1"

rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.6.1:
rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d"
dependencies:
glob "^7.0.5"

rimraf@^2.2.8:
version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
dependencies:
glob "^7.0.5"

ripemd160@^2.0.0, ripemd160@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.1.tgz#0f4584295c53a3628af7e6d79aca21ce57d1c6e7"
Expand Down Expand Up @@ -4042,10 +4070,6 @@ trim-right@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"

tryit@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb"

ts-node@^3.2.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-3.3.0.tgz#c13c6a3024e30be1180dd53038fc209289d4bf69"
Expand Down

0 comments on commit 6d2c1cd

Please sign in to comment.