import define from "../../define.js";
import { ApiError } from "../../error.js";
import { ReversiGames } from "../../../../models/index.js";
export const meta = {
    tags: [
        "reversi"
    ],
    requireCredential: false,
    errors: {
        noSuchGame: {
            message: "No such game.",
            code: "NO_SUCH_GAME",
            id: "f13a03db-fae1-46c9-87f3-43c8165419e1"
        }
    },
    res: {
        type: "object",
        optional: false,
        nullable: false
    }
};
export const paramDef = {
    type: "object",
    properties: {
        gameId: {
            type: "string",
            format: "misskey:id"
        }
    },
    required: [
        "gameId"
    ]
};
export default define(meta, paramDef, async (ps)=>{
    const game = await ReversiGames.findOne({
        where: {
            id: ps.gameId
        },
        relations: {
            user1: true,
            user2: true
        }
    });
    if (!game) throw new ApiError(meta.errors.noSuchGame);
    return await ReversiGames.packDetail(game);
});
