-
Notifications
You must be signed in to change notification settings - Fork 21
/
handler.js
28 lines (24 loc) · 883 Bytes
/
handler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module.exports = handler
/**
* @param {string} express your express app
* @returns {function} a fully configured handler function for your endpoint
*/
function handler(express){
let platform = process.env['SERVERLESS_EXPRESS_PLATFORM']
switch(platform){
case 'aws': return aws_lambda_handle(express);
case 'google': return google_cloud_function_handle(express);
case 'azure': return azure_cloud_function_handle(express);
default: throw new Error(`${platform} is not handled properly by serverless-express`);
}
}
function azure_cloud_function_handle(express){
return require('./src/azure/azure_handler')(express);
}
function aws_lambda_handle(express){
return require('./src/aws/aws_handler')(express)
}
// google cloud function are already using express
function google_cloud_function_handle(express){
return express
}