mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-10 08:01:11 +00:00
action types
This commit is contained in:
@@ -3,10 +3,11 @@ import fp from "fastify-plugin";
|
||||
import fastifyWebsocket from "fastify-websocket";
|
||||
import { createObservable } from "@monitor/util";
|
||||
import handleMessage from "./messages";
|
||||
import { Action } from "@monitor/types";
|
||||
|
||||
declare module "fastify" {
|
||||
interface FastifyInstance {
|
||||
broadcast: (message: object) => void;
|
||||
broadcast: <MessageType>(type: string, message: MessageType) => void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +16,13 @@ const ws = fp((app: FastifyInstance, _: {}, done: () => void) => {
|
||||
|
||||
const messages = createObservable();
|
||||
|
||||
app.decorate("broadcast", (msg: object) => messages.publish(msg));
|
||||
app.decorate(
|
||||
"broadcast",
|
||||
<MessageType>(type: string, msg: Action & MessageType) => {
|
||||
msg.type = type;
|
||||
messages.publish(msg);
|
||||
}
|
||||
);
|
||||
|
||||
app.get("/ws", { websocket: true, onRequest: [app.auth] }, (connection) => {
|
||||
const unsub = messages.subscribe((msg) => connection.socket.send(msg));
|
||||
|
||||
Vendored
+5
-1
@@ -17,6 +17,10 @@ export type User = {
|
||||
avatar?: string;
|
||||
};
|
||||
|
||||
export type Action = {
|
||||
type: string;
|
||||
};
|
||||
|
||||
export type Log = {
|
||||
stdout?: string;
|
||||
stderr?: string;
|
||||
@@ -93,7 +97,7 @@ export type Conversion = {
|
||||
|
||||
export interface Volume extends Conversion {
|
||||
useSystemRoot?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export type EnvironmentVar = {
|
||||
variable: string;
|
||||
|
||||
Reference in New Issue
Block a user