Skip to content

Commit

Permalink
Merge 505d7bd into ab0808c
Browse files Browse the repository at this point in the history
  • Loading branch information
greenkeeper[bot] committed Jul 26, 2020
2 parents ab0808c + 505d7bd commit 65e7c62
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install: npm ci # https://docs.travis-ci.com/user/languages/javascript-with-node

script:
- echo "Running tests against $(node -v) ..."
- npm run lint
- bash -c "[[ $(node -v) != v8* ]] && npm run lint"
- npm run test

after_success:
Expand Down
6 changes: 3 additions & 3 deletions examples/basic/data-files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<meta charset="utf-8" />
</head>

<div id="valid" style="border: 1px solid gray">
<div id="valid" style="border: 1px solid gray;">
These should all load and either be a valid image or a font:
</div>

<div id="invalid403" style="border: 1px solid gray">
<div id="invalid403" style="border: 1px solid gray;">
These each have a path that does not have a route (<code>http</code> event)
setup in serverless.yml. They should all be returning 403:
</div>

<div id="invalid404" style="border: 1px solid gray">
<div id="invalid404" style="border: 1px solid gray;">
These each have a valid route (<code>http</code> event) setup in
serverless.yml, but the file doesn't exist on disk. They should all be
returning 404:
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "prettier --write \"./**/*.{js,md,yml,json,html}\""
},
"devDependencies": {
"prettier": "^1.19.1",
"prettier": "^2.0.0",
"serverless": "^1.46.1"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions examples/serverless-offline/data-files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<meta charset="utf-8" />
</head>

<div id="valid" style="border: 1px solid gray">
<div id="valid" style="border: 1px solid gray;">
These should all load and either be a valid image or a font:
</div>

<div id="invalid403" style="border: 1px solid gray">
<div id="invalid403" style="border: 1px solid gray;">
These each have a path that does not have a route (<code>http</code> event)
setup in serverless.yml. They should all be returning 403 OR 404 (API
Gateway in prod reports them as 403, but serverless-offline reports them as
404):
</div>

<div id="invalid404" style="border: 1px solid gray">
<div id="invalid404" style="border: 1px solid gray;">
These each have a valid route (<code>http</code> event) setup in
serverless.yml, but the file doesn't exist on disk. They should all be
returning 404:
Expand Down
2 changes: 1 addition & 1 deletion examples/serverless-offline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "prettier --write \"./**/*.{js,md,yml,json,html}\""
},
"devDependencies": {
"prettier": "^1.19.1",
"prettier": "^2.0.0",
"serverless": "^1.46.1",
"serverless-offline": "^6.0.0"
},
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"js-yaml": "^3.13.1",
"mocha": "^7.0.1",
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"prettier": "^2.0.0",
"semantic-release": ">=16.0.0-beta",
"serverless": "^1.60.5",
"sinon": "^9.0.0"
Expand Down
4 changes: 2 additions & 2 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = {
"next",
"next-major",
{ name: "beta", prerelease: true },
{ name: "alpha", prerelease: true }
]
{ name: "alpha", prerelease: true },
],
}
18 changes: 10 additions & 8 deletions src/StaticFileHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class StaticFileHandler {
"Big5",
"ISO-8859-15",
"Windows-1256",
"ISO-8859-9"
"ISO-8859-9",
]
const found = textualCharSets.find(
cs => 0 === cs.localeCompare(mimeCharset, "en", { sensitivity: "base" })
(cs) => 0 === cs.localeCompare(mimeCharset, "en", { sensitivity: "base" })
)
return found === undefined || found === null
}
Expand Down Expand Up @@ -94,7 +94,7 @@ class StaticFileHandler {
requestPath = event.path
}
let filePath = path.join(this.clientFilesPath, requestPath)
return this.readFileAsResponse(filePath, context).catch(err => {
return this.readFileAsResponse(filePath, context).catch((err) => {
throw new Error(
`Unable to read client file '${requestPath}'. Error: ${err}`
)
Expand Down Expand Up @@ -161,10 +161,10 @@ class StaticFileHandler {
const response = {
statusCode: statusCode,
headers: {
"Content-Type": mimeType
"Content-Type": mimeType,
},
isBase64Encoded,
body: stringData
body: stringData,
}
return response
}
Expand All @@ -189,7 +189,7 @@ class StaticFileHandler {
filePath = path.join(__dirname, "error.html")
}
const viewData = {
errorText: errorText
errorText: errorText,
}
return this.readFileAsResponse(filePath, viewData, statusCode)
}
Expand All @@ -211,9 +211,11 @@ class StaticFileHandler {
"stageVariables",
"requestContext",
"body",
"isBase64Encoded"
"isBase64Encoded",
]
const missingProps = expectedProps.filter(propName => !(propName in event))
const missingProps = expectedProps.filter(
(propName) => !(propName in event)
)
// We're using serverless-offline which doesn't provide the `isBase64Encoded` prop, but does add the isOffline. Fixes issue #10: https://github.com/activescott/serverless-aws-static-file-handler/issues/10
const isServerlessOfflineEnvironment =
missingProps.length === 1 &&
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/BinaryMediaTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class BinaryMediaTypes {
this.provider = this.serverless.getProvider("aws")
this.commands = {
deploy: {
lifecycleEvents: ["resources"]
}
lifecycleEvents: ["resources"],
},
}
this.hooks = {
"package:compileEvents": this.packageCompileEvents.bind(this)
"package:compileEvents": this.packageCompileEvents.bind(this),
}
}

Expand All @@ -29,7 +29,7 @@ class BinaryMediaTypes {
getRestApi() {
const resources = this.serverless.service.provider
.compiledCloudFormationTemplate.Resources
return _.find(resources, r => r.Type === "AWS::ApiGateway::RestApi")
return _.find(resources, (r) => r.Type === "AWS::ApiGateway::RestApi")
}

readConfig() {
Expand Down Expand Up @@ -72,7 +72,7 @@ class BinaryMediaTypes {

BinaryMediaTypes.Strings = {
CONFIG_ERROR:
"No BinaryMediaTypes configured. See https://github.com/activescott/serverless-aws-static-file-handler#usage for information on how to configure"
"No BinaryMediaTypes configured. See https://github.com/activescott/serverless-aws-static-file-handler#usage for information on how to configure",
}

module.exports = BinaryMediaTypes

0 comments on commit 65e7c62

Please sign in to comment.