serverless-spy
Version:
CDK-based library for writing elegant integration tests on AWS serverless architecture and an additional web console to monitor events in real time.
1 lines • 1.38 kB
Source Map (JSON)
{"version":3,"file":"onConnect.mjs","names":[],"sources":["../../functions/onConnect.ts"],"sourcesContent":["import { DynamoDBClient, PutItemCommand } from '@aws-sdk/client-dynamodb';\nimport { APIGatewayEvent } from 'aws-lambda';\nimport { envVariableNames } from '../src/common/envVariableNames';\n\nconst ddb = new DynamoDBClient({\n region: process.env.AWS_REGION,\n});\n\nexports.handler = async (event: APIGatewayEvent) => {\n console.log('EVENT', JSON.stringify(event));\n\n const putParams = new PutItemCommand({\n TableName: process.env[envVariableNames.SSPY_WS_TABLE_NAME] as string,\n Item: {\n connectionId: { S: event.requestContext.connectionId! },\n },\n });\n\n try {\n await ddb.send(putParams);\n } catch (err) {\n console.error(err);\n return {\n statusCode: 500,\n body: 'Failed to connect: ' + JSON.stringify(err),\n };\n }\n\n return { statusCode: 200, body: 'Connected.' };\n};\n"],"mappings":";;;;;;;wBAEkE;CAElE,MAAM,MAAM,IAAI,eAAe,EAC7B,QAAQ,QAAQ,IAAI,YACrB,CAAC;AAEF,SAAQ,UAAU,OAAO,UAA2B;AAClD,UAAQ,IAAI,SAAS,KAAK,UAAU,MAAM,CAAC;EAE3C,MAAM,YAAY,IAAI,eAAe;GACnC,WAAW,QAAQ,IAAI,iBAAiB;GACxC,MAAM,EACJ,cAAc,EAAE,GAAG,MAAM,eAAe,cAAe,EACxD;GACF,CAAC;AAEF,MAAI;AACF,SAAM,IAAI,KAAK,UAAU;WAClB,KAAK;AACZ,WAAQ,MAAM,IAAI;AAClB,UAAO;IACL,YAAY;IACZ,MAAM,wBAAwB,KAAK,UAAU,IAAI;IAClD;;AAGH,SAAO;GAAE,YAAY;GAAK,MAAM;GAAc"}