organization refactor separating database actions, data transformations, and api type constructs into separate components

This commit is contained in:
Lucy Cifferello
2021-12-02 08:06:47 -07:00
committed by Keagan McClelland
parent fe5218925d
commit 649f876692
13 changed files with 304 additions and 283 deletions

View File

@@ -8,7 +8,6 @@ import Startlude
import Data.String.Interpolate.IsString
import Network.HTTP.Types
import Yesod.Core
import qualified Data.Text as T
type S9ErrT m = ExceptT S9Error m
@@ -18,7 +17,6 @@ data S9Error =
| NotFoundE Text
| InvalidParamsE Text Text
| AssetParseE Text Text
| DepMetadataE [Text]
deriving (Show, Eq)
instance Exception S9Error
@@ -31,9 +29,6 @@ toError = \case
NotFoundE e -> Error NOT_FOUND [i|#{e}|]
InvalidParamsE e m -> Error INVALID_PARAMS [i|Could not parse request parameters #{e}: #{m}|]
AssetParseE asset found -> Error PARSE_ERROR [i|Could not parse #{asset}: #{found}|]
DepMetadataE errs -> do
let errorText = T.concat errs
Error NOT_FOUND [i|#{errorText}|]
data ErrorCode =
DATABASE_ERROR
@@ -69,4 +64,3 @@ toStatus = \case
NotFoundE _ -> status404
InvalidParamsE _ _ -> status400
AssetParseE _ _ -> status500
DepMetadataE _ -> status404