diff --git a/functions/statusCallback.protected.ts b/functions/statusCallback.protected.ts index 9acf24b..067f99f 100644 --- a/functions/statusCallback.protected.ts +++ b/functions/statusCallback.protected.ts @@ -1,7 +1,16 @@ import { ServerlessFunctionSignature } from '@twilio-labs/serverless-runtime-types/types'; -import { StatusCallbackServerlessEventObject, TwilioEnvironmentVariables } from './types/interfaces'; +import { InsertParams, StatusCallbackServerlessEventObject, TwilioEnvironmentVariables } from './types/interfaces'; +import { connect, config, Request } from 'mssql'; -export const handler: ServerlessFunctionSignature = function( +const constructRequest = (request: Request, params: InsertParams) => { + const columns = Object.keys(params).join(", ") + const values = "@" + Object.keys(params).join(", @") + const builtRequest = Object.entries(params).reduce((req, [key, value]) => req.input(key, value), request) + + return { columns, values, builtRequest } +} + +export const handler: ServerlessFunctionSignature = async function( context, event, callback, @@ -12,7 +21,43 @@ export const handler: ServerlessFunctionSignature