UNPKG

@lighthouse-web3/sdk

Version:

NPM package and CLI tool to interact with lighthouse protocol

33 lines (32 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("../utils/util"); const lighthouse_config_1 = require("../../lighthouse.config"); exports.default = async (cid) => { try { // cid check if (!(0, util_1.isCID)(cid)) { throw new Error('Invalid CID'); } // get file info const response = await fetch(`${lighthouse_config_1.lighthouseConfig.lighthouseAPI}/api/lighthouse/file_info?cid=${cid}`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const fileInfo = (await response.json()); /* return: { "fileSizeInBytes":"15256", "cid":"QmWC9AkGa6vSbR4yizoJrFMfmZh4XjZXxvRDknk2LdJffc", "encryption":false, "fileName":"testImages", "mimeType":null, } */ return { data: fileInfo }; } catch (error) { throw new Error(error.message); } };