dispatch-server deploy
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
import {
|
||||
ConnectedAircraft,
|
||||
getPublicUser,
|
||||
MissionLog,
|
||||
Prisma,
|
||||
prisma,
|
||||
} from "@repo/db";
|
||||
import { ConnectedAircraft, getPublicUser, MissionLog, Prisma, prisma } from "@repo/db";
|
||||
import { Router } from "express";
|
||||
import { io } from "../index";
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
// Get all connectedAircrafts
|
||||
router.post("/", async (req, res) => {
|
||||
@@ -97,10 +91,7 @@ router.patch("/:id", async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
io.to("dispatchers").emit(
|
||||
"update-connectedAircraft",
|
||||
updatedConnectedAircraft,
|
||||
);
|
||||
io.to("dispatchers").emit("update-connectedAircraft", updatedConnectedAircraft);
|
||||
io.to(`user:${updatedConnectedAircraft.userId}`).emit(
|
||||
"aircraft-update",
|
||||
updatedConnectedAircraft,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { prisma } from "@repo/db";
|
||||
import { Router } from "express";
|
||||
import { pubClient } from "modules/redis";
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
const user = await prisma.connectedDispatcher.findMany({
|
||||
|
||||
@@ -2,8 +2,7 @@ import { Router } from "express";
|
||||
import { AccessToken } from "livekit-server-sdk";
|
||||
|
||||
if (!process.env.LIVEKIT_API_KEY) throw new Error("LIVEKIT_API_KEY not set");
|
||||
if (!process.env.LIVEKIT_API_SECRET)
|
||||
throw new Error("LIVEKIT_API_SECRET not set");
|
||||
if (!process.env.LIVEKIT_API_SECRET) throw new Error("LIVEKIT_API_SECRET not set");
|
||||
|
||||
const createToken = async (roomName: string) => {
|
||||
// If this room doesn't exist, it'll be automatically created when the first
|
||||
@@ -11,24 +10,19 @@ const createToken = async (roomName: string) => {
|
||||
// Identifier to be used for participant.
|
||||
// It's available as LocalParticipant.identity with livekit-client SDK
|
||||
// TODO: Move function to dispatch nextjs app as API route to use authentication of nextAuth
|
||||
const participantName =
|
||||
"quickstart-username" + Math.random().toString(36).substring(7);
|
||||
const participantName = "quickstart-username" + Math.random().toString(36).substring(7);
|
||||
|
||||
const at = new AccessToken(
|
||||
process.env.LIVEKIT_API_KEY,
|
||||
process.env.LIVEKIT_API_SECRET,
|
||||
{
|
||||
identity: participantName,
|
||||
// Token to expire after 10 minutes
|
||||
ttl: "10m",
|
||||
},
|
||||
);
|
||||
const at = new AccessToken(process.env.LIVEKIT_API_KEY, process.env.LIVEKIT_API_SECRET, {
|
||||
identity: participantName,
|
||||
// Token to expire after 10 minutes
|
||||
ttl: "10m",
|
||||
});
|
||||
at.addGrant({ roomJoin: true, room: roomName });
|
||||
|
||||
return await at.toJwt();
|
||||
};
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
router.get("/token", async (req, res) => {
|
||||
const roomName = req.query.roomName as string;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { io } from "../index";
|
||||
import { sendNtfyMission } from "modules/ntfy";
|
||||
import { sendAlert } from "modules/mission";
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
// Get all missions
|
||||
router.post("/", async (req, res) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Router } from "express";
|
||||
|
||||
import { prisma } from "@repo/db";
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
router.put("/", async (req, res) => {
|
||||
try {
|
||||
|
||||
@@ -6,7 +6,7 @@ import statusRouter from "./status";
|
||||
import aircraftsRouter from "./aircraft";
|
||||
import reportRouter from "./report";
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
router.use("/livekit", livekitRouter);
|
||||
router.use("/dispatcher", dispatcherRotuer);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { prisma } from "@repo/db";
|
||||
import { Router } from "express";
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
router.get("/connected-users", async (req, res) => {
|
||||
const connectedDispatcher = await prisma.connectedDispatcher.findMany({
|
||||
|
||||
Reference in New Issue
Block a user