This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| could not requestRemote: { | |
| "methodName": "query", | |
| "params": [ | |
| { | |
| "query": { | |
| "selector": { | |
| "borerShiftProductionId": { | |
| "$eq": "9d2d0e6f-6acb-4b9c-96e7-ba4153fa887d" | |
| } | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| getOnlineUsers = async () => { | |
| const keys = new Set(); | |
| let cursor = "0"; | |
| do { | |
| await new Promise((resolve, reject) => | |
| this.redisClient.scan( | |
| cursor, | |
| "MATCH", | |
| "session:*", | |
| "COUNT", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Save a session for a user and their online status | |
| saveSession(id: string, { username, connected }: { [key: string]: string }) { | |
| this.redisClient | |
| .multi() | |
| .hmset(`session:${id}`, "username", username, "connected", connected) | |
| .expire(`session:${id}`, SESSION_TTL) | |
| .exec(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| connectToHostedRedis = (redisEndpoint: string) => { | |
| this.pubClient = new RedisClient({ host: redisEndpoint, port: 6379 }); | |
| const subClient = this.pubClient.duplicate(); | |
| this.io.adapter(createAdapter({ pubClient: this.pubClient, subClient })); | |
| this.sessionStore = new RedisSessionStore(this.pubClient); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Request, Response } from "express"; | |
| import { createUser } from "./DynamoPuts"; | |
| import { verifyLogin } from "./DynamoQueries"; | |
| const registerRoutes = (dynamoEnabled: boolean) => { | |
| const express = require("express"); | |
| const router = express.Router(); | |
| router.post("/login", async (req: Request, res: Response) => { | |
| if (dynamoEnabled) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SocketManager { | |
| io: SocketIO.Server; | |
| pubClient: redis.RedisClient; | |
| sessionStore: RedisSessionStore; | |
| serverConfig: IServerConfig; | |
| redisEnabled: boolean; | |
| dynamoEnabled: boolean; | |
| constructor(server: http.Server, config: IServerConfig) { | |
| this.configureMiddleware(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // On the back-end | |
| this.io = new Server(server, { | |
| cors: { | |
| // Would change origin to eventual DNS for React app | |
| origin: "http://localhost:3000", | |
| methods: ["GET", "POST"], | |
| credentials: true | |
| }, | |
| allowEIO3: true, // Whether to enable compatibility with Socket.IO v2 clients. | |
| maxHttpBufferSize: 1024, // max message payload size (prevents clients from sending gigabytes of data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { joinRoom, saveRoomMessage } from "./DynamoPuts"; | |
| class SocketManager { | |
| io: SocketIO.Server; | |
| dynamoEnabled: boolean; | |
| redisEnabled: boolean; | |
| dynamoEnabled: boolean; | |
| constructor(server: http.Server, config: IServerConfig) { | |
| this.generateSocketServer(server); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Server, Socket } from "socket.io"; | |
| Class SocketManager { | |
| io: SocketIO.Server; | |
| pubClient: redis.RedisClient; | |
| sessionStore: RedisSessionStore; | |
| serverConfig: IServerConfig; | |
| redisEnabled: boolean; | |
| dynamoEnabled: boolean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createServer } from "http"; | |
| import express from "express"; | |
| import cors from "cors"; | |
| const app = express(); | |
| app.use( | |
| cors({ | |
| origin: "http://localhost:3000", | |
| methods: ["GET", "POST"], | |
| credentials: true |
NewerOlder