Skip to content

AppChat API Layer

Hint

Use our TypeScript Package on npm for super easy integration of our platform: @layer.io/api

The AppChat API is a secure chat room for your microservices. Don't bother with exposing ports or service discovery within your Kubernetes or Docker Swarm cluster. Instead, use our secure AppChat Channels for light to medium traffic between your microservices.

import * as lApi from '@layer.io/api'

const lApiAccount = lapi.createAccount('your secret api key here');

/*
send any messages you want.
You are totally free in creating your own payloads.
*/
interface IMyMessageType: {
  eventName: 'newUser' | 'deletedUser';
  userData: {
    'firstName': string;
    'lastName';
  }
}

/*
Note: Rooms are created within the layer.io dashboard.
We plan on adding dynamic room creation and room discovery later on.
*/
const myAppChatRoom = lApiAccount.connectToAppChatRoom<IMyMessageType>('myRoom1', 'mySecureRoomPassword');

// go reactive with rxjs Observables
myAppChatRoom.getObservable().subscribe(messageArg => {
  // do something whenever a message arricves
});

myAppChatRoom.sendMessage({
  eventName: 'newUser',
  userData: {
    'firstName': 'Peter';
    'lastName': 'Kunz';
  }
})

Yes! We publish this as Open Source

Our chatroom implementation is based on our very own @pushrocks/smartuniverse! If you feel like it use it to spawn your own appchat! :)