How to use the @laconia/adapter-api.webSocket function in @laconia/adapter-api

To help you get started, we’ve selected a few @laconia/adapter-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github laconiajs / laconia / packages / laconia-acceptance-test / src / update-user-receipt.js View on Github external
const WebSocketClient = require("./WebSocketClient");

const instances = ({ event, env }) => ({
  wsClient: new WebSocketClient(
    env.WEBSOCKET_ENDPOINT,
    event.requestContext.connectionId
  )
});

const app = async (message, { wsClient }) => {
  if (message.body.message === "order received") {
    return wsClient.send({ message: "thank you for your order" });
  }
};

const webSocket = adapterApi.webSocket();

exports.handler = laconia(webSocket(app)).register(instances, {
  cache: { enabled: false }
});

@laconia/adapter-api

Converts API Gateway Proxy events into your application input

Apache-2.0
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis