🔧 Added a single import socket.io endpoint

This commit is contained in:
2022-04-25 20:08:07 -07:00
parent bb9dbc2e47
commit dc4767db27

View File

@@ -1,15 +1,10 @@
"use strict"; "use strict";
import { import { Service, ServiceBroker, ServiceSchema } from "moleculer";
Service,
ServiceBroker,
ServiceSchema
} from "moleculer";
const SocketIOService = require("moleculer-io"); const SocketIOService = require("moleculer-io");
const redisAdapter = require("socket.io-redis"); const redisAdapter = require("socket.io-redis");
const redisURL = new URL(process.env.REDIS_URI); const redisURL = new URL(process.env.REDIS_URI);
console.log(redisURL.hostname); console.log(redisURL.hostname);
export default class SocketService extends Service { export default class SocketService extends Service {
// @ts-ignore // @ts-ignore
public constructor( public constructor(
@@ -56,14 +51,19 @@ export default class SocketService extends Service {
{} {}
); );
break; break;
case "LS_SINGLE_IMPORT":
console.log(data.data);
break;
} }
} },
}, },
}, },
}, },
options: { options: {
adapter: redisAdapter({ host: redisURL.hostname, port: 6379 }) adapter: redisAdapter({
host: redisURL.hostname,
port: 6379,
}),
}, },
}, },
}, },
@@ -71,8 +71,10 @@ export default class SocketService extends Service {
actions: {}, actions: {},
methods: {}, methods: {},
async started() { async started() {
this.io.on("connection", (data) => console.log("socket.io server initialized.")) this.io.on("connection", (data) =>
} console.log("socket.io server initialized.")
);
},
}, },
schema schema
) )