module IHP.DataSync.REST.Routes where import IHP.RouterPrelude import IHP.DataSync.REST.Types instance CanRoute ApiController where parseRoute' :: (?context::RequestContext) => Parser ApiController parseRoute' = do ByteString -> Parser ByteString string ByteString "/api/" let graphQLQueryAction :: Parser ApiController graphQLQueryAction = do ByteString -> Parser ByteString string ByteString "graphql" Parser ByteString () forall t. Chunk t => Parser t () endOfInput (?context::RequestContext) => [StdMethod] -> Parser ByteString () [StdMethod] -> Parser ByteString () onlyAllowMethods [StdMethod POST] ApiController -> Parser ApiController forall a. a -> Parser ByteString a forall (f :: * -> *) a. Applicative f => a -> f a pure ApiController GraphQLQueryAction createRecordAction :: Text -> Parser ApiController createRecordAction Text table = do Parser ByteString () forall t. Chunk t => Parser t () endOfInput (?context::RequestContext) => [StdMethod] -> Parser ByteString () [StdMethod] -> Parser ByteString () onlyAllowMethods [StdMethod POST] ApiController -> Parser ApiController forall a. a -> Parser ByteString a forall (f :: * -> *) a. Applicative f => a -> f a pure CreateRecordAction { Text table :: Text table :: Text table } updateOrDeleteRecordAction :: Text -> Parser ApiController updateOrDeleteRecordAction Text table = do ByteString -> Parser ByteString string ByteString "/" UUID id <- Parser UUID parseUUID Parser ByteString () forall t. Chunk t => Parser t () endOfInput StdMethod method <- Parser StdMethod (?context::RequestContext) => Parser StdMethod getMethod case StdMethod method of StdMethod PATCH -> ApiController -> Parser ApiController forall a. a -> Parser ByteString a forall (f :: * -> *) a. Applicative f => a -> f a pure UpdateRecordAction { Text table :: Text table :: Text table, UUID id :: UUID id :: UUID id } StdMethod GET -> ApiController -> Parser ApiController forall a. a -> Parser ByteString a forall (f :: * -> *) a. Applicative f => a -> f a pure ShowRecordAction { Text table :: Text table :: Text table, UUID id :: UUID id :: UUID id } StdMethod DELETE -> ApiController -> Parser ApiController forall a. a -> Parser ByteString a forall (f :: * -> *) a. Applicative f => a -> f a pure DeleteRecordAction { Text table :: Text table :: Text table, UUID id :: UUID id :: UUID id } listRecordsAction :: Text -> Parser ApiController listRecordsAction Text table = do Parser ByteString () forall t. Chunk t => Parser t () endOfInput StdMethod method <- Parser StdMethod (?context::RequestContext) => Parser StdMethod getMethod case StdMethod method of StdMethod GET -> ApiController -> Parser ApiController forall a. a -> Parser ByteString a forall (f :: * -> *) a. Applicative f => a -> f a pure ListRecordsAction { Text table :: Text table :: Text table } crud :: Parser ApiController crud = do Text table <- Parser Text parseText (?context::RequestContext) => Text -> Parser ApiController Text -> Parser ApiController updateOrDeleteRecordAction Text table Parser ApiController -> Parser ApiController -> Parser ApiController forall a. Parser ByteString a -> Parser ByteString a -> Parser ByteString a forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> (?context::RequestContext) => Text -> Parser ApiController Text -> Parser ApiController createRecordAction Text table Parser ApiController -> Parser ApiController -> Parser ApiController forall a. Parser ByteString a -> Parser ByteString a -> Parser ByteString a forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> (?context::RequestContext) => Text -> Parser ApiController Text -> Parser ApiController listRecordsAction Text table Parser ApiController graphQLQueryAction Parser ApiController -> Parser ApiController -> Parser ApiController forall a. Parser ByteString a -> Parser ByteString a -> Parser ByteString a forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> Parser ApiController crud instance HasPath ApiController where pathTo :: ApiController -> Text pathTo CreateRecordAction { Text table :: ApiController -> Text table :: Text table } = Text "/api/" Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text table pathTo UpdateRecordAction { Text table :: ApiController -> Text table :: Text table, UUID id :: ApiController -> UUID id :: UUID id } = Text "/api/" Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text table Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text "/" Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> UUID -> Text forall a. Show a => a -> Text tshow UUID id pathTo DeleteRecordAction { Text table :: ApiController -> Text table :: Text table, UUID id :: ApiController -> UUID id :: UUID id } = Text "/api/" Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text table Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text "/" Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> UUID -> Text forall a. Show a => a -> Text tshow UUID id pathTo ApiController GraphQLQueryAction = Text "/api/graphql"