feat(server): added in admin section of socketio

This commit is contained in:
2026-01-26 06:27:54 -06:00
parent 152f7042c9
commit 81bd4d6dcb
5 changed files with 314 additions and 31 deletions

View File

@@ -0,0 +1,51 @@
import type { Server as HttpServer } from "node:http";
//import { dirname, join } from "node:path";
//import { fileURLToPath } from "node:url";
import { instrument } from "@socket.io/admin-ui";
import { Server } from "socket.io";
//const __filename = fileURLToPath(import.meta.url);
//const __dirname = dirname(__filename);
export const setupSocketIORoutes = (baseUrl: string, server: HttpServer) => {
const io = new Server(server, {
path: `${baseUrl}/api/socket.io`,
cors: {
origin: ["http://localhost:3000", "https://admin.socket.io"],
credentials: true,
},
});
io.on("connection", (s) => {
console.info(s.id);
});
// admin stuff for socket io
// app.use(
// express.static(
// join(__dirname, "../../../node_modules/@socket.io/admin-ui/dist"),
// ),
// );
// app.get(baseUrl + "/admindashboard", (_, res) => {
// res.sendFile(
// join(
// __dirname,
// "../../../node_modules/@socket.io/admin-ui/dist/index.js",
// ),
// );
// });
const admin = io.of("/admin");
admin.on("connection", () => {
console.info("Connected to admin userspace");
});
instrument(io, {
auth: false,
//namespaceName: "/admin",
});
//setup all the routes
// app.use(`${baseUrl}/api/datamart`, runQuery);
// app.use(`${baseUrl}/api/datamart`, addQuery);
// app.use(`${baseUrl}/api/datamart`, updateQuery);
// just sending a get on datamart will return all the queries that we can call.
};

View File

@@ -9,6 +9,8 @@ export const allowedOrigins = [
"http://localhost:4000",
"http://localhost:4001",
"http://localhost:5500",
"https://admin.socket.io",
"https://electron-socket-io-playground.vercel.app",
`${process.env.URL}`,
];
export const lstCors = () => {