Skip to content

Commit

Permalink
update node version
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Mar 1, 2021
1 parent a02cfd1 commit 5ead458
Show file tree
Hide file tree
Showing 7 changed files with 1,271 additions and 1,087 deletions.
1 change: 1 addition & 0 deletions handler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'source-map-support/register'
import imageH from './src/imageHandler'
import storeH from './src/storeHandler'
import researchH from './src/researchHandler'
Expand Down
2,290 changes: 1,233 additions & 1,057 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gtin-cloud",
"version": "1.2.8",
"version": "1.2.9",
"description": "GTIN cloud storage strategy",
"main": "handler.js",
"scripts": {
Expand All @@ -23,34 +23,34 @@
"dependencies": {
"cherio": "^1.0.0-rc.2",
"debug": "^4.3.1",
"got": "^11.8.1",
"got": "^11.8.2",
"random-useragent": "^0.5.0",
"scrape-it": "^5.3.1",
"source-map-support": "^0.5.19",
"webpack-node-externals": "^2.5.2",
"xml-js": "^1.6.11"
},
"devDependencies": {
"@babel/cli": "^7.12.16",
"@babel/core": "^7.12.16",
"@babel/plugin-transform-runtime": "^7.12.15",
"@babel/preset-env": "^7.12.16",
"@babel/register": "^7.12.13",
"@babel/runtime": "^7.12.13",
"aws-sdk": "^2.843.0",
"@babel/cli": "^7.13.0",
"@babel/core": "^7.13.8",
"@babel/plugin-transform-runtime": "^7.13.8",
"@babel/preset-env": "^7.13.8",
"@babel/register": "^7.13.8",
"@babel/runtime": "^7.13.8",
"aws-sdk": "^2.854.0",
"babel-loader": "^8.2.2",
"babel-plugin-source-map-support": "^2.1.3",
"copy-webpack-plugin": "^7.0.0",
"cross-env": "^7.0.3",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint": "^7.21.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jest": "^24.1.5",
"jest": "^26.6.3",
"js-yaml": "^4.0.0",
"serverless": "^2.23.0",
"serverless": "^2.28.0",
"serverless-offline": "^6.8.0",
"serverless-webpack": "^5.3.5",
"webpack": "^5.21.2"
"webpack": "^5.24.2",
"webpack-node-externals": "^2.5.2"
}
}
16 changes: 9 additions & 7 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@ custom:

provider:
name: aws
runtime: nodejs12.x
runtime: nodejs14.x
stage: ${opt:stage, 'dev'}
region: us-east-1
timeout: 29
memorySize: 512
apiKeys:
- ${opt:stage, 'dev'}-key
- ${opt:stage, 'dev'}-han
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:*"
Resource:
- "*"
iam:
role:
statements:
- Effect: "Allow"
Action:
- "s3:*"
Resource:
- "*"
# To load environment variables externally
# rename env.example to env.yml and uncomment
# the following line. Also, make sure to not
Expand Down
10 changes: 7 additions & 3 deletions src/primaryVendors.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ class Handlers {
skip: 0,
take: 1
}
let myGtin = `0000000000000${gtin}`.slice(-14)
let myGtin = `0000000000000${gtin}`.slice(-14)
let product = {}
let image = imageUrl

try {
const rst = await got.post(url, { json, headers, searchParams, responseType: 'json' })
let product = rst.body.Results[0]
let image = imageUrl

product = rst.body.Results[0]

if (product && product.Components && image == null) {
product.gtin = myGtin
Expand All @@ -159,6 +161,8 @@ class Handlers {
await Promise.all(rsp.tasks)
}
}
} else {
debug('Product not found', rst.body)
}

return product
Expand Down
2 changes: 1 addition & 1 deletion src/researchHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default async (event, context, callback) => {
return rspHandler(`${gtin} must be at least 12 characters`, 422)
}

debug(`started for ${gtin}`)
debug(`started for ${gtin} ${vendor}`)
let data = null
let myGtin = `00000000000000${gtin}`.slice(-14)

Expand Down
9 changes: 5 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const slsw = require('serverless-webpack')
// const nodeExternals = require('webpack-node-externals')
const slsw = require('serverless-webpack')
const nodeExternals = require('webpack-node-externals')

module.exports = {
entry: slsw.lib.entries,
Expand All @@ -8,11 +8,12 @@ module.exports = {
devtool: 'source-map',
// Since 'aws-sdk' is not compatible with webpack,
// we exclude all node dependencies
// externals: [nodeExternals()],
externals: [nodeExternals()],
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
optimization: {
// We do not want to minimize our code.
minimize: false,
concatenateModules: false
},
performance: {
// Turn off size warnings for entry points
Expand All @@ -27,7 +28,7 @@ module.exports = {
loader: 'babel-loader',
include: __dirname,
exclude: /node_modules/,
}
},
],
},
}

0 comments on commit 5ead458

Please sign in to comment.