mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-13 17:25:36 +02:00
fix: Move more directories
This commit is contained in:
24
cloud/packages/core/src/realtime/index.ts
Normal file
24
cloud/packages/core/src/realtime/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
IoTDataPlaneClient,
|
||||
PublishCommand,
|
||||
} from "@aws-sdk/client-iot-data-plane";
|
||||
import { Actor } from "../actor";
|
||||
import { Resource } from "sst";
|
||||
|
||||
export namespace Realtime {
|
||||
const client = new IoTDataPlaneClient({});
|
||||
|
||||
export async function publish(message: any, subTopic?: string) {
|
||||
const fingerprint = Actor.assert("machine").properties.fingerprint;
|
||||
let topic = `${Resource.App.name}/${Resource.App.stage}/${fingerprint}/`;
|
||||
if (subTopic)
|
||||
topic = `${topic}${subTopic}`;
|
||||
|
||||
await client.send(
|
||||
new PublishCommand({
|
||||
payload: Buffer.from(JSON.stringify(message)),
|
||||
topic: topic,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user