@sinch/functions-runtime 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1028,6 +1028,8 @@ export interface VoiceFunction {
1028
1028
  notify?: NotifyHandler;
1029
1029
  /** Default handler for GET / */
1030
1030
  default?: ApiHandler;
1031
+ /** Root route handler — TypeScript-friendly alias for 'default' */
1032
+ home?: ApiHandler;
1031
1033
  /** Custom API endpoints (any other exported function) */
1032
1034
  [key: string]: unknown;
1033
1035
  }
package/dist/index.js CHANGED
@@ -1128,7 +1128,10 @@ async function handleVoiceCallback(functionName, userFunction, context, callback
1128
1128
  return formatSvamlResponse(result, functionName);
1129
1129
  }
1130
1130
  async function handleCustomEndpoint(functionName, userFunction, context, request, logger) {
1131
- const handler = userFunction[functionName];
1131
+ let handler = userFunction[functionName];
1132
+ if ((!handler || typeof handler !== "function") && functionName === "default") {
1133
+ handler = userFunction["home"];
1134
+ }
1132
1135
  if (!handler || typeof handler !== "function") {
1133
1136
  throw new Error(`Function '${functionName}' not found in function.js`);
1134
1137
  }