aws-lambda-fastify
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -60,2 +60,5 @@ module.exports = (app, options) => (event, context, callback) => { | ||
} else res.headers[h] = res.headers[h].join(',') | ||
} else if (typeof res.headers[h] !== 'undefined' && typeof res.headers[h] !== 'string') { | ||
// NOTE: API Gateway (i.e. HttpApi) validates all headers to be a string | ||
res.headers[h] = res.headers[h].toString() | ||
} | ||
@@ -62,0 +65,0 @@ }) |
@@ -34,3 +34,3 @@ { | ||
], | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"main": "index.js", | ||
@@ -37,0 +37,0 @@ "scripts": { |
@@ -23,3 +23,3 @@ # Introduction | ||
const awsLambdaFastify = require('aws-lambda-fastify') | ||
const app = require('./app'); | ||
const app = require('./app') | ||
@@ -30,9 +30,9 @@ const proxy = awsLambdaFastify(app) | ||
exports.handler = proxy; | ||
exports.handler = proxy | ||
// or | ||
// exports.handler = (event, context, callback) => proxy(event, context, callback); | ||
// exports.handler = (event, context, callback) => proxy(event, context, callback) | ||
// or | ||
// exports.handler = (event, context) => proxy(event, context); | ||
// exports.handler = (event, context) => proxy(event, context) | ||
// or | ||
// exports.handler = async (event, context) => proxy(event, context); | ||
// exports.handler = async (event, context) => proxy(event, context) | ||
``` | ||
@@ -43,6 +43,6 @@ | ||
```js | ||
const fastify = require('fastify'); | ||
const fastify = require('fastify') | ||
const app = fastify(); | ||
app.get('/', (request, reply) => reply.send({ hello: 'world' })); | ||
const app = fastify() | ||
app.get('/', (request, reply) => reply.send({ hello: 'world' })) | ||
@@ -52,8 +52,8 @@ if (require.main === module) { | ||
app.listen(3000, (err) => { | ||
if (err) console.error(err); | ||
console.log('server listening on 3000'); | ||
}); | ||
if (err) console.error(err) | ||
console.log('server listening on 3000') | ||
}) | ||
} else { | ||
// required as a module => executed on aws lambda | ||
module.exports = app; | ||
module.exports = app | ||
} | ||
@@ -77,3 +77,3 @@ ``` | ||
const event = JSON.parse(decodeURIComponent(request.headers['x-apigateway-event'])) | ||
const context = JSON.parse(decodeURIComponent(request.headers['x-apigateway-context']))}); | ||
const context = JSON.parse(decodeURIComponent(request.headers['x-apigateway-context'])) | ||
// ... | ||
@@ -80,0 +80,0 @@ }) |
10145
74