From a9400d9079a10dbb4cd53ec10c93db8f38d5b48d Mon Sep 17 00:00:00 2001 From: xecarlox94 Date: Sat, 9 Nov 2024 21:28:31 +0000 Subject: [PATCH] moving API code --- haskell/lib/Error.hs | 1 + haskell/lib/P2Prc.hs | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/haskell/lib/Error.hs b/haskell/lib/Error.hs index 92c1e21..ad4fd9c 100644 --- a/haskell/lib/Error.hs +++ b/haskell/lib/Error.hs @@ -16,4 +16,5 @@ assignError = MkUnknownError -- -- TODO: add error when internet connection is off -- +-- Left (MkUnknownError "Unexpected end-of-input, expecting JSON value") -- MkSystemError 1 "/home/xecarlox/Desktop/p2p-rendering-computation/p2p-rendering-computation" "2024/11/09 21:08:06 Get \"http://0.0.0.0:8088/MAPPort?port=3333&domain_name=\": dial tcp 0.0.0.0:8088: connect: connection refused\n" diff --git a/haskell/lib/P2Prc.hs b/haskell/lib/P2Prc.hs index 5aa03f7..6ae52e8 100644 --- a/haskell/lib/P2Prc.hs +++ b/haskell/lib/P2Prc.hs @@ -1,15 +1,15 @@ {-# LANGUAGE OverloadedStrings #-} -module P2Prc ( runP2Prc ) - where +module P2Prc ( runP2Prc ) where - -import System.Process ( ProcessHandle, terminateProcess ) +import System.Process + ( ProcessHandle + , terminateProcess + ) import Control.Concurrent ( threadDelay ) - -import Data.Aeson +import Data.Aeson ( FromJSON ) import Environment ( cleanEnvironment ) @@ -23,6 +23,14 @@ import JSON ) import CLI + ( StdInput(..) + , CLIOpt(..) + , eitherErrDecode + , getP2PrcCmd + , eitherExecProcess + , eitherExecProcessParser + , spawnProcP2Prc + ) -- URGENT TASKS @@ -47,9 +55,6 @@ import CLI -- TODO: add use case examples (extra-source_files) - --- Module: API - runP2Prc :: IO () runP2Prc = do @@ -135,6 +140,7 @@ runP2Prc = do (Left err) -> print err +-- Module: API data P2prAPI = MkP2prAPI { startServer :: IOEitherError ProcessHandle