Compare commits

...

No commits in common. "2d3c229608c6c6cc6be21b93f6ef4d4232b9dc4d" and "2c404dce2f9ede1eaa6f07c3c51d861c771a5632" have entirely different histories.

2 changed files with 27 additions and 2 deletions

View File

@ -1,5 +1,19 @@
# Soostone
## Start
First create tables:
```sh
soostone create-tables
```
Then start backend:
```sh
soostone run
```
## Request examples
### Insert

View File

@ -21,6 +21,7 @@ versioner :: Parser (a -> a)
versioner = infoOption (showVersion version) (long "version" <> help "Show version" <> hidden)
data Command = Run ServerConfig
| Create ServerConfig
data Config = Config {
serverCommand :: Command
@ -60,6 +61,14 @@ parseCommands = subparser $
( progDesc "Run the REST API webserver"
)
)
<>
command
"create-tables"
(info
(Create <$> parseServerConf <**> helper)
( progDesc "Create the database"
)
)
main :: IO ()
@ -70,12 +79,14 @@ main = do
case serverCommand of
Run ServerConfig{..} -> do
when (sqliteDB == ":memory:") $ fail "In-memory DB is not supported!"
con <- open sqliteDB
createTables con
let appState = AppState { sqliteFile = sqliteDB }
void $ register ghcMetrics
void $ register procMetrics
run serverPort (middleWare $ app appState)
Create ServerConfig{..} -> do
when (sqliteDB == ":memory:") $ fail "In-memory DB is not supported!"
con <- open sqliteDB
createTables con
where
createTables :: Connection -> IO ()
createTables con = do