// adapters/login.adapter.js

function mapLoginRequestToLoginInput(body) {
  return {
    email: (body?.email || "").trim().toLowerCase(),
    password: body?.password || "",
  };
}

function mapLoginResultToResponse(result) {
  // result: { token, user }
  return {
    token: result.token,
    user: {
      id: result.user.id,
      username: result.user.username,
      email: result.user.email,
      avatarUrl: result.user.avatarUrl ?? null,
    },
  };
}

module.exports = {
  mapLoginRequestToLoginInput,
  mapLoginResultToResponse,
};
