import "./types.d.ts"; import { InternalServerError } from "@platform/relay"; import { context } from "@platform/relay"; import { getStorageContext, storage } from "@platform/storage"; import { SocketRegistry } from "./sockets.ts"; export const sockets = new SocketRegistry(); export default { /** * TODO ... */ bootstrap: async (): Promise => { Object.defineProperties(context, { /** * TODO ... */ sockets: { get() { const sockets = storage.getStore()?.sockets; if (sockets === undefined) { throw new InternalServerError("Sockets not defined."); } return sockets; }, }, }); }, /** * TODO ... */ resolve: async (): Promise => { const context = getStorageContext(); context.sockets = sockets; }, };