examples icon indicating copy to clipboard operation
examples copied to clipboard

included aws-node-websockets to community examples

Open Ascendzor opened this issue 6 years ago • 2 comments

Ascendzor avatar May 05 '19 11:05 Ascendzor

Thanks for sharing @Ascendzor ... the build is failing though. Could you regenerate the README?

Also, I took a look at your repo, specifically your note about the aws-sdk lambda version. The following "trick" snippet might be helpful to add to the example. It basically injects the new websockets service into Lambda's aws-sdk. Once you have this in your Lambda code, you won't need to deploy the entire aws-sdk everytime, which reduces deployment time.

// handler.js

'use strict';

const AWS = require('aws-sdk')

// the following section injects the new ApiGatewayManagementApi service
// into the Lambda AWS SDK, otherwise you'll have to deploy the entire new version of the SDK

/* START ApiGatewayManagementApi injection */
const { Service, apiLoader } = AWS

apiLoader.services['apigatewaymanagementapi'] = {}

const model = {
  metadata: {
    apiVersion: '2018-11-29',
    endpointPrefix: 'execute-api',
    signingName: 'execute-api',
    serviceFullName: 'AmazonApiGatewayManagementApi',
    serviceId: 'ApiGatewayManagementApi',
    protocol: 'rest-json',
    jsonVersion: '1.1',
    uid: 'apigatewaymanagementapi-2018-11-29',
    signatureVersion: 'v4'
  },
  operations: {
    PostToConnection: {
      http: {
        requestUri: '/@connections/{connectionId}',
        responseCode: 200
      },
      input: {
        type: 'structure',
        members: {
          Data: {
            type: 'blob'
          },
          ConnectionId: {
            location: 'uri',
            locationName: 'connectionId'
          }
        },
        required: ['ConnectionId', 'Data'],
        payload: 'Data'
      }
    }
  },
  paginators: {},
  shapes: {}
}

AWS.ApiGatewayManagementApi = Service.defineService('apigatewaymanagementapi', ['2018-11-29'])
Object.defineProperty(apiLoader.services['apigatewaymanagementapi'], '2018-11-29', {
  // eslint-disable-next-line
  get: function get() {
    return model
  },
  enumerable: true,
  configurable: true
})
/* END ApiGatewayManagementApi injection */

module.exports.connect = (event, context, cb) => {
  cb(null, {
    statusCode: 200,
    body: 'Connected.'
  });
};

eahefnawy avatar May 06 '19 07:05 eahefnawy

@Ascendzor Hey there. Thanks again for adding the example. Just checking in to see if you need any assistance with correcting the issues outlined by the CI engine as per Eslam's advice above?

garethmcc avatar May 29 '19 10:05 garethmcc