feat: initial commit at project root

This commit is contained in:
Hamza-Ayed
2026-05-29 01:06:47 +03:00
commit 87ec54bbd7
22 changed files with 1737 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import crypto from 'crypto';
/**
* Generates a cryptographically secure UUID version 4.
* @returns {string}
*/
export function generateUUIDv4() {
return crypto.randomUUID();
}
/**
* Session models an active call coordination session.
*/
export class Session {
/**
* @param {string} rideID
* @param {string} driverID
* @param {string} passengerID
* @param {number} durationMs
* @param {string} [driverIP]
* @param {string} [passengerIP]
*/
constructor(rideID, driverID, passengerID, durationMs, driverIP = null, passengerIP = null) {
this.sessionID = generateUUIDv4();
this.rideID = rideID;
this.driverID = driverID;
this.passengerID = passengerID;
this.driverIP = driverIP;
this.passengerIP = passengerIP;
this.createdAt = new Date();
this.expiresAt = new Date(this.createdAt.getTime() + durationMs);
this.status = 'waiting'; // "waiting" | "active" | "ended"
this.driverConn = null;
this.passengerConn = null;
this.timer = null;
}
}