Rename client and server to backend and frontend

This commit is contained in:
Saku Laesvuori 2023-09-25 21:54:02 +03:00
parent ae983ca167
commit 513a3e11f5
Signed by: slaesvuo
GPG Key ID: 257D284A2A1D3A32
30 changed files with 114 additions and 114 deletions

View File

@ -18,11 +18,11 @@
(or (git-predicate (string-append (current-source-directory) "/../.."))
(const #t)))
(define-public datarekisteri-server
(define-public datarekisteri-backend
(package
(name "datarekisteri-server")
(name "datarekisteri-backend")
(version "0.0.1")
(source (local-file "../../server" "datarekisteri-server-checkout"
(source (local-file "../../backend" "datarekisteri-backend-checkout"
#:recursive? #t
#:select? vcs-file?))
(build-system haskell-build-system)
@ -48,18 +48,18 @@
(add-after 'install 'wrap-binaries
(lambda _
(wrap-program
(string-append #$output "/bin/datarekisteri-server")
(string-append #$output "/bin/datarekisteri-backend")
`("PATH" prefix (,(string-append #$(this-package-input "dbmate") "/bin")))))))))
(home-page "")
(synopsis "")
(description "")
(license license:agpl3+)))
(define-public datarekisteri-client
(define-public datarekisteri-frontend
(package
(name "datarekisteri-client")
(name "datarekisteri-frontend")
(version "0.0.1")
(source (local-file "../../client" "datarekisteri-client-checkout"
(source (local-file "../../frontend" "datarekisteri-frontend-checkout"
#:recursive? #t
#:select? vcs-file?))
(build-system haskell-build-system)
@ -982,4 +982,4 @@ for writing tests which print some outputs using @code{fmt} package.")
multiple developers and your production servers.")
(license license:expat)))
(list datarekisteri-server datarekisteri-client ghc-datarekisteri-core)
(list datarekisteri-backend datarekisteri-frontend ghc-datarekisteri-core)

View File

@ -1,5 +1,5 @@
cabal-version: 3.6
name: datarekisteri-server
name: datarekisteri-backend
version: 0.0.1
author: Saku Laesvuori
license: AGPL-3.0-or-later
@ -9,7 +9,7 @@ stability: alpha
data-files:
db/migrations/*.sql
executable datarekisteri-server
executable datarekisteri-backend
build-depends:
aeson,
base,
@ -41,16 +41,16 @@ executable datarekisteri-server
wai-cors,
wai-extra,
directory
main-is: Server.hs
main-is: Datarekisteri/Backend.hs
other-modules:
Server.API,
Server.DB,
Server.DB.Queries,
Server.Email,
Server.Types,
Server.Utils,
Paths_datarekisteri_server
Datarekisteri.Backend.API,
Datarekisteri.Backend.DB,
Datarekisteri.Backend.DB.Queries,
Datarekisteri.Backend.Email,
Datarekisteri.Backend.Types,
Datarekisteri.Backend.Utils,
Paths_datarekisteri_backend
autogen-modules:
Paths_datarekisteri_server
Paths_datarekisteri_backend
hs-source-dirs: src
default-language: Haskell2010

View File

@ -19,18 +19,18 @@ import Network.Wai (Application)
import Network.Wai.Handler.Warp (Port, run)
import Network.Wai.Middleware.Cors
import Network.Wai.Middleware.Gzip
import Server.API
import Server.DB
import Server.DB.Queries (getUserByEmail, getPermissions, getToken)
import Server.Types
import Server.Utils (checkPassword)
import Datarekisteri.Backend.API
import Datarekisteri.Backend.DB
import Datarekisteri.Backend.DB.Queries (getUserByEmail, getPermissions, getToken)
import Datarekisteri.Backend.Types
import Datarekisteri.Backend.Utils (checkPassword)
import System.Directory (findExecutable)
import System.Process (callProcess)
import Options.Applicative hiding (header)
import qualified Options.Applicative as O
import Web.Scotty.Trans hiding (readEither)
import qualified "base64" Data.ByteString.Base64 as B64 (decodeBase64)
import Paths_datarekisteri_server
import Paths_datarekisteri_backend
main :: IO ()
main = do
@ -57,7 +57,7 @@ configOpts = Config
<$> optional (strOption (long "sender-name" <> short 'n' <> metavar "NAME" <> help "Display name for email address"))
<*> strOption (long "address" <> short 'a' <> metavar "EMAIL" <> help "Email address to send mail"))
<*> option auto (long "port" <> short 'p' <> metavar "PORT" <> value 3100 <> help "Port to listen on")
<*> strOption (long "db-url" <> short 'u' <> metavar "URL" <> value "postgres:///id.rekisteri" <> help "Postgresql database url")
<*> strOption (long "db-url" <> short 'u' <> metavar "URL" <> value "postgres:///datarekisteri-backend" <> help "Postgresql database url")
runMigrations :: Text -> IO ()
runMigrations dbUrl = do

View File

@ -16,7 +16,7 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Server.API (coreApp, runApp, resolver) where
module Datarekisteri.Backend.API (coreApp, runApp, resolver) where
import Relude hiding (Undefined, void, when, get)
@ -29,11 +29,11 @@ import Data.Morpheus.Types (Arg(..), GQLType, GQLError, App)
import Data.Time (nominalDay)
import Database.Persist (Entity, entityVal, entityKey, get, (=.))
import Datarekisteri.Core.Types
import Server.DB
import Server.DB.Queries
import Server.Email (sendVerificationEmail)
import Server.Types
import Server.Utils
import Datarekisteri.Backend.DB
import Datarekisteri.Backend.DB.Queries
import Datarekisteri.Backend.Email (sendVerificationEmail)
import Datarekisteri.Backend.Types
import Datarekisteri.Backend.Utils
import qualified "base64" Data.ByteString.Base64 as B64 (encodeBase64)
import qualified Data.Text as T (null, chunksOf, intercalate)

View File

@ -12,7 +12,7 @@
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
module Server.DB where
module Datarekisteri.Backend.DB where
import Data.ByteString (ByteString)
import Data.Text (Text)
@ -21,7 +21,7 @@ import Database.Persist (Entity, Key, entityKey, PersistEntity)
import Database.Persist.Sql (fromSqlKey, toSqlKey)
import Database.Persist.Postgresql.JSON (Value)
import Datarekisteri.Core.Types
import Server.Types
import Datarekisteri.Backend.Types
mkPersist sqlSettings [persistUpperCase|
DBUser sql=users

View File

@ -4,10 +4,10 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
module Server.DB.Queries where
module Datarekisteri.Backend.DB.Queries where
import Server.DB as DB
import Server.Types
import Datarekisteri.Backend.DB as DB
import Datarekisteri.Backend.Types
import Datarekisteri.Core.Types
import Data.Text (Text)
import Database.Esqueleto.Experimental

View File

@ -1,8 +1,8 @@
{-# LANGUAGE OverloadedStrings #-}
module Server.Email where
module Datarekisteri.Backend.Email where
import Server.Types
import Datarekisteri.Backend.Types
import Data.Text (Text)
import Data.Text.Lazy (fromStrict)
import Datarekisteri.Core.Types

View File

@ -9,7 +9,7 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Server.Types where
module Datarekisteri.Backend.Types where
import Relude

View File

@ -1,6 +1,6 @@
{-# LANGUAGE PackageImports #-}
module Server.Utils where
module Datarekisteri.Backend.Utils where
import Data.ByteArray.Encoding (convertToBase, Base(..))
import Data.ByteString (ByteString)
@ -8,7 +8,7 @@ import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Data.Text (Text)
import qualified Crypto.KDF.BCrypt as Crypt (hashPassword, validatePassword)
import "cryptonite" Crypto.Random (MonadRandom)
import Server.Types
import Datarekisteri.Backend.Types
base32 :: ByteString -> Text
base32 = decodeUtf8 . convertToBase Base32

View File

@ -1,31 +0,0 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Client.Handlers
( module Client.Handlers.Profile
, module Client.Handlers.Apply
, module Client.Handlers.Applications
, module Client.Handlers.VerifyEmail
, module Client.Handlers.Members
, getHomeR
) where
import Relude
import Client.Handlers.Profile
import Client.Handlers.Apply
import Client.Handlers.Applications
import Client.Handlers.VerifyEmail
import Client.Handlers.Members
import Client.Types
import Yesod
import Yesod.Auth
getHomeR :: Handler Html
getHomeR = ifM (isJust <$> maybeAuthId) (redirect OwnProfileR) (redirect $ AuthR LoginR)

View File

@ -1,5 +1,5 @@
cabal-version: 3.6
name: datarekisteri-client
name: datarekisteri-frontend
version: 0.0.1
author: Saku Laesvuori
license: AGPL-3.0-or-later
@ -7,7 +7,7 @@ license-file: COPYING.md
build-type: Simple
stability: alpha
executable datarekisteri-client
executable datarekisteri-frontend
build-depends:
aeson,
base,
@ -35,17 +35,17 @@ executable datarekisteri-client
yesod-core,
yesod-static,
directory
main-is: Client.hs
main-is: Frontend.hs
other-modules:
Client.ApiRequests,
Client.Auth,
Client.FormFields,
Client.Handlers,
Client.Handlers.Applications,
Client.Handlers.Apply,
Client.Handlers.Profile,
Client.Handlers.VerifyEmail,
Client.Handlers.Members,
Client.Types
Datarekisteri.Frontend.ApiRequests,
Datarekisteri.Frontend.Auth,
Datarekisteri.Frontend.FormFields,
Datarekisteri.Frontend.Handlers,
Datarekisteri.Frontend.Handlers.Applications,
Datarekisteri.Frontend.Handlers.Apply,
Datarekisteri.Frontend.Handlers.Profile,
Datarekisteri.Frontend.Handlers.VerifyEmail,
Datarekisteri.Frontend.Handlers.Members,
Datarekisteri.Frontend.Types
hs-source-dirs: src
default-language: Haskell2010

View File

@ -9,7 +9,7 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.ApiRequests where
module Datarekisteri.Frontend.ApiRequests where
import Relude

View File

@ -10,7 +10,7 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.Auth where
module Datarekisteri.Frontend.Auth where
import Relude

View File

@ -3,12 +3,12 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.FormFields where
module Datarekisteri.Frontend.FormFields where
import Relude
import Yesod
import Client.Types
import Datarekisteri.Frontend.Types
import Datarekisteri.Core.Types
emailField :: Field Handler Email

View File

@ -0,0 +1,31 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Datarekisteri.Frontend.Handlers
( module Datarekisteri.Frontend.Handlers.Profile
, module Datarekisteri.Frontend.Handlers.Apply
, module Datarekisteri.Frontend.Handlers.Applications
, module Datarekisteri.Frontend.Handlers.VerifyEmail
, module Datarekisteri.Frontend.Handlers.Members
, getHomeR
) where
import Relude
import Datarekisteri.Frontend.Handlers.Profile
import Datarekisteri.Frontend.Handlers.Apply
import Datarekisteri.Frontend.Handlers.Applications
import Datarekisteri.Frontend.Handlers.VerifyEmail
import Datarekisteri.Frontend.Handlers.Members
import Datarekisteri.Frontend.Types
import Yesod
import Yesod.Auth
getHomeR :: Handler Html
getHomeR = ifM (isJust <$> maybeAuthId) (redirect OwnProfileR) (redirect $ AuthR LoginR)

View File

@ -10,17 +10,17 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.Handlers.Applications where
module Datarekisteri.Frontend.Handlers.Applications where
import Relude hiding (id)
import Client.ApiRequests
import Client.Types
import Datarekisteri.Frontend.ApiRequests
import Datarekisteri.Frontend.Types
import Data.Morpheus.Client
import Datarekisteri.Core.Types hiding (Applications)
import Yesod hiding (emailField)
import Yesod.Auth
import Client.FormFields
import Datarekisteri.Frontend.FormFields
import Data.Time (Day)
import Data.Maybe (fromJust)

View File

@ -10,17 +10,17 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.Handlers.Apply where
module Datarekisteri.Frontend.Handlers.Apply where
import Relude hiding (id)
import Client.ApiRequests
import Client.Types
import Datarekisteri.Frontend.ApiRequests
import Datarekisteri.Frontend.Types
import Data.Morpheus.Client
import Datarekisteri.Core.Types
import Yesod hiding (emailField)
import Yesod.Auth
import Client.FormFields
import Datarekisteri.Frontend.FormFields
import Data.Time (Day)
declareLocalTypesInline "schema.gql" [raw|

View File

@ -8,13 +8,13 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.Handlers.Members where
module Datarekisteri.Frontend.Handlers.Members where
import Relude hiding (id)
import Data.Morpheus.Client
import Client.Types
import Client.ApiRequests
import Datarekisteri.Frontend.Types
import Datarekisteri.Frontend.ApiRequests
import Datarekisteri.Core.Types
import Yesod
import Yesod.Auth

View File

@ -10,13 +10,13 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.Handlers.Profile where
module Datarekisteri.Frontend.Handlers.Profile where
import Relude hiding (id)
import Client.ApiRequests
import Client.Types
import Client.FormFields
import Datarekisteri.Frontend.ApiRequests
import Datarekisteri.Frontend.Types
import Datarekisteri.Frontend.FormFields
import Data.Morpheus.Client
import Datarekisteri.Core.Types
import Yesod hiding (emailField)

View File

@ -9,12 +9,12 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.Handlers.VerifyEmail where
module Datarekisteri.Frontend.Handlers.VerifyEmail where
import Relude
import Client.ApiRequests
import Client.Types
import Datarekisteri.Frontend.ApiRequests
import Datarekisteri.Frontend.Types
import Datarekisteri.Core.Types
import Data.Morpheus.Client
import Yesod

View File

@ -13,7 +13,7 @@
{-# LANGUAGE NoImplicitPrelude #-}
module Client.Types where
module Datarekisteri.Frontend.Types where
import Relude hiding (id)
import Relude.Extra.Foldable1 (maximum1)
@ -26,8 +26,8 @@ import Yesod.Static
import Datarekisteri.Core.Types (UserID(..), Scope(..), Permission(..), readPermission)
import Data.Time (getCurrentTime)
import Data.Time.Format.ISO8601 (iso8601Show)
import Client.Auth
import Client.ApiRequests
import Datarekisteri.Frontend.Auth
import Datarekisteri.Frontend.ApiRequests
import Data.Morpheus.Client
import Data.Map (findWithDefault)

View File

@ -15,9 +15,9 @@ import Relude hiding (get)
import Yesod
import Yesod.Auth
import Client.Types
import Client.Handlers
import Client.Auth ()
import Datarekisteri.Frontend.Types
import Datarekisteri.Frontend.Handlers
import Datarekisteri.Frontend.Auth ()
import Yesod.Static (static, Static)
import Options.Applicative
import System.Directory (createDirectoryIfMissing)