import { Kuzzle, WebSocket, Http } from "kuzzle-sdk";

const kuzzle = new Kuzzle(new Http("localhost"));

kuzzle.on("networkError", (error: any) => {
  console.error("Network Error: ", error);
});

const run = async () => {
  try {
    // Connects to the Kuzzle server
    await kuzzle.connect();
    // Creates an index
    // await kuzzle.index.create("nyc-open-data");
    // // Creates a collection
    // await kuzzle.collection.create("nyc-open-data", "yellow-taxi", {});
    // console.log("nyc-open-data/yellow-taxi ready!");
    return kuzzle;
  } catch (error: any) {
    console.error(error.message);
  } 
//   finally {
//     kuzzle.disconnect(); 
//   }
  return null;
};
export { run };
