Skip to content

Commit

Permalink
docs: add UPGRADE.md
Browse files Browse the repository at this point in the history
  • Loading branch information
brett-vendia committed Feb 1, 2021
1 parent 2656818 commit c9c623b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
35 changes: 35 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## From 3.x to 4.x

```javascript
// 3.x
const awsServerlessExpress = require('aws-serverless-express')
const app = require('./app')

const binaryMimeTypes = [
'image/*'
]
const server = awsServerlessExpress.createServer(app, null, binaryMimeTypes)

exports.handler = (event, context) => { awsServerlessExpress.proxy(server, event, context) }
```

```javascript
// 4.x
const serverlessExpress = require('@vendia/serverless-express')
const app = require('./app')

exports.handler = serverlessExpress({ app }).handler
```

In v4.x, `binaryMimeTypes` isn't required as the `isBase64Encoded` Lambda response value is automatically determined based on the `content-encoding` and `content-type` headers returned by your application. If you need additional control over this, you can specify `binarySettings`:

```javascript
serverlessExpress({
app,
binarySettings: {
isBinary: ({ headers }) => true,
contentTypes: [],
contentEncodings: []
}
})
```
2 changes: 1 addition & 1 deletion src/configure.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface ConfigureParams {

interface BinarySettings {
isBinary?: Function | boolean,
contentTypes: string[]
contentTypes?: string[]
}

interface ConfigureResult {
Expand Down
4 changes: 2 additions & 2 deletions src/proxy.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { RequestListener } from "http"
interface ProxyParams {
app: RequestListener,
binaryMimeTypes?: string[],
binarySettings: BinarySettings
binarySettings?: BinarySettings
}

interface BinarySettings {
isBinary?: Function | boolean,
contentTypes: string[]
contentTypes?: string[]
}

declare function proxy(proxyParams: ProxyParams): Promise<any>
Expand Down

0 comments on commit c9c623b

Please sign in to comment.