import { type FastifyReply, type FastifyRequest } from "fastify"; import { getDB } from "../../store/store.js"; import { hashPassword } from "../../services/auth/auth.js"; import { getUserFromAuth } from "../../services/auth/helpers.js"; const getPing = async (_request: FastifyRequest, _reply: FastifyReply) => { return [{ message: "pong" }]; }; const getTest = async (_request: FastifyRequest, _reply: FastifyReply) => { const authHeader = _request.headers["authorization"]; return [{ user: await getUserFromAuth(authHeader) }]; const owner = await getDB().user.create({ data: { username: "TestUser", passwordHash: await hashPassword("29144"), email: "testuser@aslan2142.space", admin: true, }, }); await getDB().community.create({ data: { name: "TestCommunity", ownerId: owner.id, members: { connect: { id: owner.id, }, create: [ { username: "Aslo", passwordHash: await hashPassword("pass"), admin: false, }, { username: "Aslan", passwordHash: await hashPassword("8556"), email: "aslan@aslan2142.space", admin: false, }, ], }, }, }); return [{ message: "ok" }]; }; export { getPing, getTest };