#pragma once #include #include #include using namespace geode::prelude; namespace server { struct ServerDateTime final { using Clock = std::chrono::system_clock; using Value = std::chrono::time_point; Value value; std::string toAgoString() const; static Result parse(std::string const& str); }; struct ServerDeveloper { std::string username; std::string displayName; }; struct ServerModVersion { ModMetadata metadata; std::string downloadURL; std::string hash; size_t downloadCount; static Result parse(matjson::Value const& json); }; struct ServerModMetadata { std::string id; bool featured; size_t downloadCount; std::vector developers; std::vector versions; std::unordered_set tags; std::optional about; std::optional changelog; std::optional createdAt; std::optional updatedAt; static Result parse(matjson::Value const& json); }; struct ServerModsList { std::vector mods; size_t totalModCount = 0; static Result parse(matjson::Value const& json); }; enum class ModsSort { Downloads, RecentlyUpdated, RecentlyPublished, }; static const char* sortToString(ModsSort sorting); struct ModsQuery { std::optional query; std::unordered_set platforms = { GEODE_PLATFORM_TARGET }; std::unordered_set tags; std::optional featured; ModsSort sorting = ModsSort::Downloads; std::optional developer; size_t page = 0; size_t pageSize = 10; }; struct ServerError { int code; std::string details; ServerError() = default; template ServerError( int code, fmt::string_view format, Args&&... args ) : code(code), details(fmt::vformat(format, fmt::make_format_args(args...))) {} }; template using ServerPromise = Promise; std::string getServerAPIBaseURL(); std::string getServerUserAgent(); ServerPromise getMods(ModsQuery const& query); ServerPromise getMod(std::string const& id); ServerPromise getModLogo(std::string const& id); }