1.1.0 • Published 1 year ago

aws-pubsub v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

aws-pubsub

Introduction

Target of this small library is to quickly have a possibility to do realtime-communication between multiple clients and/or servers i.e. for a chat-application. The Lib is usable in nodejs applications and in the browser aswell.

Prerequisites

To use this library you need a AWSAppSync Realtime API endpoint with an valid API-Key. In your AWS Account just switch to AppSync service and create such an API:

npm.io

npm.io

After creating you need the endpoint URL and you have to create an API-Key. You need that information to call the configure method of the lib.

npm.io

Usage

pubsub.configure({
    aws_appsync_graphqlEndpoint:
        'https://xxxxxxxxxxxxxxxx.appsync-api.eu-central-1.amazonaws.com/graphql',
    aws_appsync_region: 'eu-central-1',
    aws_appsync_authenticationType: 'API_KEY',
    aws_appsync_apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxx',
});

pubsub.subscribe(
    'myChannel',
    (data) => {
        console.log('received data', data);
    },
    (error) => {
        // error handling
    },
);

pubsub.publish(
    'myChannel',
    JSON.stringify({ name: 'A Friend', message: 'Hello World from a friend' }),
)
1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago