Courier is an publish/subscriber socket to broadcast messages to every susbscription.
207
Courier is an publish/subscriber socket to broadcast messages to every susbscription. All communication must be authenticated with a valid JWT token.
Courier needs you to customize the environment vars for your system.
COURIER_PRODUCTION=false
COURIER_PORT=8883
COURIER_HOST="localhost"
COURIER_WS_URL="ws://localhost:8883/ws"
COURIER_DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
COURIER_DATABASE_NAMESPACE="courier"
COURIER_JWT_SECRET="3EK6FD+o0+c7tzBNVfjpMkNDi2yARAAKzQlk8O2IKoxQu4nF7EdAh8s3TwpHwrdWT6R"
COURIER_KEY_SECRET="kNDKzQlk8ONVfjpMKo2I75tg67ujmki8"
For more info goto project on github.
Courier provide endpoints to manage the service. With this endpoints you will be able to create audience, obtain a signed url to use socket service and a hook enpoint to send messages to pub/sub.
Create a audience to group content and connections communications. Audience (aud) should be define in your JWT token. All endpoints are secure with a valid JWT. If you need a system to administrate user sign, etc please consider use gotrue system.
Creates and audience from your jwt token
Returns
{
"id": "11111111-2222-3333-4444-5555555555555",
"name": "my-audience.com",
"created_at": "2016-05-15T19:53:12.368652374-07:00",
"updated_at": "2016-05-15T19:53:12.368652374-07:00"
}
Creates and a topic for a audience (jwt will give audience)
{
"topic": "system/events"
}
}
Returns
```json
{
"id": "11111111-2222-3333-4444-5555555555555",
"topic": "system/events",
"audience": "...",
"audienceId": "11111111-2222-3333-4444-5555555555555",
"created_at": "2016-05-15T19:53:12.368652374-07:00",
"updated_at": "2016-05-15T19:53:12.368652374-07:00"
}
Get topics for a audience (jwt will give audience)
Returns
[{
"id": "11111111-2222-3333-4444-5555555555555",
"topic": "system/events",
"audience": "...",
"audienceId": "11111111-2222-3333-4444-5555555555555",
"created_at": "2016-05-15T19:53:12.368652374-07:00",
"updated_at": "2016-05-15T19:53:12.368652374-07:00"
}]
Hook endpoint to publish events (message has to be object)
{
"topic": "system/events",
"action": "publish",
"message": {
"type": "database"
...
}
}
Returns same object from body
Obtain a signed to url to connect to socket. JWT audience will be use to generate your secure connection.
Returns
{
"key": "8p2uzHww5V6tMdOMJKyxdUDYDzw6DyE2yucduoKtM_HwpXNR0JvHK_KanL9xX1bTlkjJ3lj5eZ2hOr0x-OQZfOFQcd2n4ukUQ2Tde1dXkLOvAMBbpJt14Fe",
"url": "ws://localhost:8883/ws?token=8p2uzHww5V6tMdOMJKyxdUDYDzw6DyE2yucduoKtM_HwpXNR0JvHK_KanL9xX1bTlkjJ3lj5eZ2hOr0x-OQZfOFQcd2n4ukUQ2Tde1dXkLOvAMBbpJt14Fe"
}
Pub/Sub allows you to subscribe, unsubscribe, publish and broadcasts messages. After get a valid signed url the followings signatures for each type are:
{
"action": "subscribe",
"topic": "system/events"
}
{
"action": "unsubscribe",
"topic": "system/events"
}
{
"action": "publish",
"topic": "system/events",
"message": {} //always object
}
{
"action": "broadcast",
"message": {} //always object
}
Content type
Image
Digest
Size
12.9 MB
Last updated
over 5 years ago
docker pull websublime/courier