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) "/../..")) (or (git-predicate (string-append (current-source-directory) "/../.."))
(const #t))) (const #t)))
(define-public datarekisteri-server (define-public datarekisteri-backend
(package (package
(name "datarekisteri-server") (name "datarekisteri-backend")
(version "0.0.1") (version "0.0.1")
(source (local-file "../../server" "datarekisteri-server-checkout" (source (local-file "../../backend" "datarekisteri-backend-checkout"
#:recursive? #t #:recursive? #t
#:select? vcs-file?)) #:select? vcs-file?))
(build-system haskell-build-system) (build-system haskell-build-system)
@ -48,18 +48,18 @@
(add-after 'install 'wrap-binaries (add-after 'install 'wrap-binaries
(lambda _ (lambda _
(wrap-program (wrap-program
(string-append #$output "/bin/datarekisteri-server") (string-append #$output "/bin/datarekisteri-backend")
`("PATH" prefix (,(string-append #$(this-package-input "dbmate") "/bin"))))))))) `("PATH" prefix (,(string-append #$(this-package-input "dbmate") "/bin")))))))))
(home-page "") (home-page "")
(synopsis "") (synopsis "")
(description "") (description "")
(license license:agpl3+))) (license license:agpl3+)))
(define-public datarekisteri-client (define-public datarekisteri-frontend
(package (package
(name "datarekisteri-client") (name "datarekisteri-frontend")
(version "0.0.1") (version "0.0.1")
(source (local-file "../../client" "datarekisteri-client-checkout" (source (local-file "../../frontend" "datarekisteri-frontend-checkout"
#:recursive? #t #:recursive? #t
#:select? vcs-file?)) #:select? vcs-file?))
(build-system haskell-build-system) (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.") multiple developers and your production servers.")
(license license:expat))) (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 cabal-version: 3.6
name: datarekisteri-server name: datarekisteri-backend
version: 0.0.1 version: 0.0.1
author: Saku Laesvuori author: Saku Laesvuori
license: AGPL-3.0-or-later license: AGPL-3.0-or-later
@ -9,7 +9,7 @@ stability: alpha
data-files: data-files:
db/migrations/*.sql db/migrations/*.sql
executable datarekisteri-server executable datarekisteri-backend
build-depends: build-depends:
aeson, aeson,
base, base,
@ -41,16 +41,16 @@ executable datarekisteri-server
wai-cors, wai-cors,
wai-extra, wai-extra,
directory directory
main-is: Server.hs main-is: Datarekisteri/Backend.hs
other-modules: other-modules:
Server.API, Datarekisteri.Backend.API,
Server.DB, Datarekisteri.Backend.DB,
Server.DB.Queries, Datarekisteri.Backend.DB.Queries,
Server.Email, Datarekisteri.Backend.Email,
Server.Types, Datarekisteri.Backend.Types,
Server.Utils, Datarekisteri.Backend.Utils,
Paths_datarekisteri_server Paths_datarekisteri_backend
autogen-modules: autogen-modules:
Paths_datarekisteri_server Paths_datarekisteri_backend
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010

View File

@ -19,18 +19,18 @@ import Network.Wai (Application)
import Network.Wai.Handler.Warp (Port, run) import Network.Wai.Handler.Warp (Port, run)
import Network.Wai.Middleware.Cors import Network.Wai.Middleware.Cors
import Network.Wai.Middleware.Gzip import Network.Wai.Middleware.Gzip
import Server.API import Datarekisteri.Backend.API
import Server.DB import Datarekisteri.Backend.DB
import Server.DB.Queries (getUserByEmail, getPermissions, getToken) import Datarekisteri.Backend.DB.Queries (getUserByEmail, getPermissions, getToken)
import Server.Types import Datarekisteri.Backend.Types
import Server.Utils (checkPassword) import Datarekisteri.Backend.Utils (checkPassword)
import System.Directory (findExecutable) import System.Directory (findExecutable)
import System.Process (callProcess) import System.Process (callProcess)
import Options.Applicative hiding (header) import Options.Applicative hiding (header)
import qualified Options.Applicative as O import qualified Options.Applicative as O
import Web.Scotty.Trans hiding (readEither) import Web.Scotty.Trans hiding (readEither)
import qualified "base64" Data.ByteString.Base64 as B64 (decodeBase64) import qualified "base64" Data.ByteString.Base64 as B64 (decodeBase64)
import Paths_datarekisteri_server import Paths_datarekisteri_backend
main :: IO () main :: IO ()
main = do main = do
@ -57,7 +57,7 @@ configOpts = Config
<$> optional (strOption (long "sender-name" <> short 'n' <> metavar "NAME" <> help "Display name for email address")) <$> 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")) <*> 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") <*> 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 :: Text -> IO ()
runMigrations dbUrl = do runMigrations dbUrl = do

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
{-# LANGUAGE OverloadedStrings #-} {-# 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 (Text)
import Data.Text.Lazy (fromStrict) import Data.Text.Lazy (fromStrict)
import Datarekisteri.Core.Types import Datarekisteri.Core.Types

View File

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

View File

@ -1,6 +1,6 @@
{-# LANGUAGE PackageImports #-} {-# LANGUAGE PackageImports #-}
module Server.Utils where module Datarekisteri.Backend.Utils where
import Data.ByteArray.Encoding (convertToBase, Base(..)) import Data.ByteArray.Encoding (convertToBase, Base(..))
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
@ -8,7 +8,7 @@ import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Data.Text (Text) import Data.Text (Text)
import qualified Crypto.KDF.BCrypt as Crypt (hashPassword, validatePassword) import qualified Crypto.KDF.BCrypt as Crypt (hashPassword, validatePassword)
import "cryptonite" Crypto.Random (MonadRandom) import "cryptonite" Crypto.Random (MonadRandom)
import Server.Types import Datarekisteri.Backend.Types
base32 :: ByteString -> Text base32 :: ByteString -> Text
base32 = decodeUtf8 . convertToBase Base32 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 cabal-version: 3.6
name: datarekisteri-client name: datarekisteri-frontend
version: 0.0.1 version: 0.0.1
author: Saku Laesvuori author: Saku Laesvuori
license: AGPL-3.0-or-later license: AGPL-3.0-or-later
@ -7,7 +7,7 @@ license-file: COPYING.md
build-type: Simple build-type: Simple
stability: alpha stability: alpha
executable datarekisteri-client executable datarekisteri-frontend
build-depends: build-depends:
aeson, aeson,
base, base,
@ -35,17 +35,17 @@ executable datarekisteri-client
yesod-core, yesod-core,
yesod-static, yesod-static,
directory directory
main-is: Client.hs main-is: Frontend.hs
other-modules: other-modules:
Client.ApiRequests, Datarekisteri.Frontend.ApiRequests,
Client.Auth, Datarekisteri.Frontend.Auth,
Client.FormFields, Datarekisteri.Frontend.FormFields,
Client.Handlers, Datarekisteri.Frontend.Handlers,
Client.Handlers.Applications, Datarekisteri.Frontend.Handlers.Applications,
Client.Handlers.Apply, Datarekisteri.Frontend.Handlers.Apply,
Client.Handlers.Profile, Datarekisteri.Frontend.Handlers.Profile,
Client.Handlers.VerifyEmail, Datarekisteri.Frontend.Handlers.VerifyEmail,
Client.Handlers.Members, Datarekisteri.Frontend.Handlers.Members,
Client.Types Datarekisteri.Frontend.Types
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010

View File

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

View File

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

View File

@ -3,12 +3,12 @@
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
module Client.FormFields where module Datarekisteri.Frontend.FormFields where
import Relude import Relude
import Yesod import Yesod
import Client.Types import Datarekisteri.Frontend.Types
import Datarekisteri.Core.Types import Datarekisteri.Core.Types
emailField :: Field Handler Email 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 #-} {-# LANGUAGE NoImplicitPrelude #-}
module Client.Handlers.Applications where module Datarekisteri.Frontend.Handlers.Applications where
import Relude hiding (id) import Relude hiding (id)
import Client.ApiRequests import Datarekisteri.Frontend.ApiRequests
import Client.Types import Datarekisteri.Frontend.Types
import Data.Morpheus.Client import Data.Morpheus.Client
import Datarekisteri.Core.Types hiding (Applications) import Datarekisteri.Core.Types hiding (Applications)
import Yesod hiding (emailField) import Yesod hiding (emailField)
import Yesod.Auth import Yesod.Auth
import Client.FormFields import Datarekisteri.Frontend.FormFields
import Data.Time (Day) import Data.Time (Day)
import Data.Maybe (fromJust) import Data.Maybe (fromJust)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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