upd
This commit is contained in:
@@ -37,6 +37,9 @@ const activeSessionSchema = new Schema(
|
||||
connectedPlayersCount: {
|
||||
type: Number,
|
||||
},
|
||||
endAt: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
import { Router } from "express";
|
||||
import ActiveSession from "../models/ActiveSession";
|
||||
import { isValidObjectId } from "mongoose";
|
||||
// import { isValidObjectId } from "mongoose";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get("/:id", async (req, res) => {
|
||||
const activeSessionId = req.params.id;
|
||||
|
||||
if (!isValidObjectId(activeSessionId)) {
|
||||
return res.json({ status: "error", message: "Invalid ObjectId" });
|
||||
}
|
||||
// if (!isValidObjectId(activeSessionId)) {
|
||||
// return res.json({ status: "error", message: "Invalid ObjectId" });
|
||||
// }
|
||||
|
||||
try {
|
||||
const activeSession = await ActiveSession.findById(activeSessionId);
|
||||
await ActiveSession.findByIdAndUpdate(activeSessionId, {
|
||||
updatedAt: new Date(),
|
||||
});
|
||||
|
||||
console.log("activeSession", activeSession);
|
||||
|
||||
res.json(activeSession);
|
||||
} catch (error) {
|
||||
res.json({ error: (error as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
const activeSessionRouter = router;
|
||||
|
||||
@@ -18,9 +18,7 @@ router.get("/", async (req, res) => {
|
||||
|
||||
res.json({ countryCode });
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
res.json({ error: error.message });
|
||||
}
|
||||
res.json({ error: (error as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user