mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
69 lines
1.1 KiB
JavaScript
69 lines
1.1 KiB
JavaScript
'use strict'
|
|
|
|
async function minimal(event) {
|
|
return {
|
|
statusCode: 200,
|
|
body: JSON.stringify({
|
|
message: 'Hello from API Gateway! - (minimal)',
|
|
event,
|
|
}),
|
|
}
|
|
}
|
|
|
|
async function cors(event) {
|
|
return {
|
|
statusCode: 200,
|
|
headers: {
|
|
'Access-Control-Allow-Origin': '*',
|
|
},
|
|
body: JSON.stringify({
|
|
message: 'Hello from API Gateway! - (cors)',
|
|
event,
|
|
}),
|
|
}
|
|
}
|
|
|
|
async function customAuthorizers(event) {
|
|
return {
|
|
statusCode: 200,
|
|
body: JSON.stringify({
|
|
message: 'Hello from API Gateway! - (customAuthorizers)',
|
|
event,
|
|
}),
|
|
}
|
|
}
|
|
|
|
async function apiKeys(event) {
|
|
return {
|
|
statusCode: 200,
|
|
body: JSON.stringify({
|
|
message: 'Hello from API Gateway! - (apiKeys)',
|
|
event,
|
|
}),
|
|
}
|
|
}
|
|
|
|
async function timeout(event) {
|
|
return new Promise((resolve) =>
|
|
setTimeout(
|
|
() =>
|
|
resolve({
|
|
statusCode: 200,
|
|
body: JSON.stringify({
|
|
message: 'Should not happen (timeout expected)',
|
|
event,
|
|
}),
|
|
}),
|
|
2000,
|
|
),
|
|
)
|
|
}
|
|
|
|
module.exports = {
|
|
minimal,
|
|
cors,
|
|
customAuthorizers,
|
|
apiKeys,
|
|
timeout,
|
|
}
|