mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
module.exports.hello = async () => {
|
|
console.log('This log is from the "hello" .cjs handler')
|
|
|
|
return {
|
|
statusCode: 200,
|
|
body: 'Hello',
|
|
}
|
|
}
|
|
|
|
module.exports.event = async (event) => {
|
|
console.log('This log is from the "event" .cjs handler')
|
|
|
|
return {
|
|
statusCode: 200,
|
|
body: event,
|
|
}
|
|
}
|
|
|
|
module.exports.environment = async () => {
|
|
console.log('This log is from the "environment" .cjs handler')
|
|
|
|
return {
|
|
statusCode: 200,
|
|
body: process.env.FOO,
|
|
}
|
|
}
|
|
|
|
module.exports.error = async () => {
|
|
console.log('This log is from the "error" .cjs handler')
|
|
throw new Error('This error should not fail the test')
|
|
}
|
|
|
|
module.exports.context = async (event, context) => {
|
|
console.log('This log is from the "context" .cjs handler')
|
|
|
|
const contextWithoutFunctions = Object.keys(context)
|
|
.filter((key) => typeof context[key] !== 'function')
|
|
.reduce((acc, key) => {
|
|
acc[key] = context[key]
|
|
return acc
|
|
}, {})
|
|
|
|
return contextWithoutFunctions
|
|
}
|
|
|
|
module.exports.callback = (event, context, callback) => {
|
|
console.log('This log is from the "callback" .cjs handler')
|
|
|
|
callback(null, 'Hello')
|
|
}
|