SpaceNinjaServer/src/controllers/api/hostSessionController.ts

19 lines
845 B
TypeScript
Raw Normal View History

2023-05-19 15:22:48 -03:00
import { RequestHandler } from "express";
2024-05-28 13:45:06 +02:00
import { getAccountIdForRequest } from "@/src/services/loginService";
import { createNewSession } from "@/src/managers/sessionManager";
2024-01-06 16:26:58 +01:00
import { logger } from "@/src/utils/logger";
import { ISession } from "@/src/types/session";
2023-05-23 20:53:26 -04:00
// eslint-disable-next-line @typescript-eslint/no-misused-promises
2024-05-28 13:45:06 +02:00
const hostSessionController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
2024-01-06 16:26:58 +01:00
const hostSessionRequest = JSON.parse(req.body as string) as ISession;
logger.debug("HostSession Request", { hostSessionRequest });
2024-05-28 13:45:06 +02:00
const session = createNewSession(hostSessionRequest, accountId);
2024-01-06 16:26:58 +01:00
logger.debug(`New Session Created`, { session });
2023-06-01 17:08:05 -07:00
res.json({ sessionId: { $id: session.sessionId }, rewardSeed: 99999999 });
2023-05-19 15:22:48 -03:00
};
export { hostSessionController };