feat: modular domain driven boilerplate
This commit is contained in:
39
platform/socket/server.ts
Normal file
39
platform/socket/server.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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<void> => {
|
||||
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<void> => {
|
||||
const context = getStorageContext();
|
||||
context.sockets = sockets;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user