From a044398552eb7fa5ae5a61b11dda441cd4261005 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 4 Feb 2016 16:27:54 -0800 Subject: [PATCH 1/6] Adjust usage message to indicate required arguments --- src/PostgREST/Config.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PostgREST/Config.hs b/src/PostgREST/Config.hs index f7392335e..d1e1e6676 100644 --- a/src/PostgREST/Config.hs +++ b/src/PostgREST/Config.hs @@ -47,11 +47,11 @@ data AppConfig = AppConfig { argParser :: Parser AppConfig argParser = AppConfig - <$> argument str (help "database connection string" <> metavar "STRING") + <$> argument str (help "(REQUIRED) database connection string" <> metavar "DB_URL") <*> option auto (long "port" <> short 'p' <> help "port number on which to run HTTP server" <> metavar "PORT" <> value 3000 <> showDefault) - <*> strOption (long "anonymous" <> short 'a' <> help "postgres role to use for non-authenticated requests" <> metavar "ROLE") - <*> strOption (long "schema" <> short 's' <> help "schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault) + <*> strOption (long "anonymous" <> short 'a' <> help "(REQUIRED) postgres role to use for non-authenticated requests" <> metavar "ROLE") + <*> strOption (long "schema" <> short 's' <> help "(REQUIRED) schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault) <*> (secret . cs <$> strOption (long "jwt-secret" <> short 'j' <> help "secret used to encrypt and decrypt JWT tokens" <> metavar "SECRET" <> value "secret" <> showDefault)) <*> option auto (long "pool" <> short 'o' <> help "max connections in database pool" <> metavar "COUNT" <> value 10 <> showDefault) From 7702d3826701d4a6c9ad1d09c23d6fcb3c7da0e0 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 4 Feb 2016 16:33:04 -0800 Subject: [PATCH 2/6] Update docs to note rquired arguments --- docs/install/server.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/install/server.md b/docs/install/server.md index e5aa4663d..325d17a14 100644 --- a/docs/install/server.md +++ b/docs/install/server.md @@ -65,7 +65,7 @@ If you want to run the test suite, stack can do that too: `stack test`. ### Running the Server ```bash -postgrest postgres://user:pass@host:port/db [flags] +postgrest postgres://user:pass@host:port/db -s public -a anon_user [other flags] ``` The user in the connection string is the "authenticator role," i.e. @@ -80,11 +80,11 @@ The possible flags are:
The port on which the server will listen for HTTP requests. Defaults to 3000.
-
-a, --anonymous
+
-a, --anonymous (required)
The database role used to execute commands for those requests which provide no JWT authorization.
-
-s, --schema
+
-s, --schema (required)
The db schema which you want to expose as an API. For historical reasons it defaults to 1, but you're more likely to want to choose a value of public.
From 56426b896ab9132a8589100e51a753cbc594ca54 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 4 Feb 2016 16:38:35 -0800 Subject: [PATCH 3/6] Changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a266e9945..82511e64b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased ### Fixed +- Improved usage screen - @begriffs - Reject non-POSTs to rpc endpoints - @begriffs - Throw an error for OPTIONS on nonexistent tables - @calebmer From ccb3eba9e30f2132029999a64fbd8c5ff5c60c3c Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Fri, 5 Feb 2016 09:27:24 -0800 Subject: [PATCH 4/6] Reorder arg list, note that schema is not required --- docs/install/server.md | 6 +++--- src/PostgREST/Config.hs | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/install/server.md b/docs/install/server.md index 325d17a14..14d8dfcc8 100644 --- a/docs/install/server.md +++ b/docs/install/server.md @@ -65,7 +65,7 @@ If you want to run the test suite, stack can do that too: `stack test`. ### Running the Server ```bash -postgrest postgres://user:pass@host:port/db -s public -a anon_user [other flags] +postgrest postgres://user:pass@host:port/db -a anon_user [other flags] ``` The user in the connection string is the "authenticator role," i.e. @@ -73,7 +73,7 @@ a role which is used temporarily to switch into other roles depending on the authentication request JWT. For simple API's you can use the same role for authenticator and anonymous. -The possible flags are: +The complete list of options:
-p, --port
@@ -84,7 +84,7 @@ The possible flags are:
The database role used to execute commands for those requests which provide no JWT authorization.
-
-s, --schema (required)
+
-s, --schema
The db schema which you want to expose as an API. For historical reasons it defaults to 1, but you're more likely to want to choose a value of public.
diff --git a/src/PostgREST/Config.hs b/src/PostgREST/Config.hs index d1e1e6676..8c60ef553 100644 --- a/src/PostgREST/Config.hs +++ b/src/PostgREST/Config.hs @@ -37,9 +37,9 @@ import Prelude -- | Data type to store all command line options data AppConfig = AppConfig { configDatabase :: String - , configPort :: Int , configAnonRole :: String , configSchema :: String + , configPort :: Int , configJwtSecret :: Secret , configPool :: Int , configMaxRows :: Maybe Integer @@ -48,10 +48,9 @@ data AppConfig = AppConfig { argParser :: Parser AppConfig argParser = AppConfig <$> argument str (help "(REQUIRED) database connection string" <> metavar "DB_URL") - - <*> option auto (long "port" <> short 'p' <> help "port number on which to run HTTP server" <> metavar "PORT" <> value 3000 <> showDefault) <*> strOption (long "anonymous" <> short 'a' <> help "(REQUIRED) postgres role to use for non-authenticated requests" <> metavar "ROLE") - <*> strOption (long "schema" <> short 's' <> help "(REQUIRED) schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault) + <*> strOption (long "schema" <> short 's' <> help "schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault) + <*> option auto (long "port" <> short 'p' <> help "port number on which to run HTTP server" <> metavar "PORT" <> value 3000 <> showDefault) <*> (secret . cs <$> strOption (long "jwt-secret" <> short 'j' <> help "secret used to encrypt and decrypt JWT tokens" <> metavar "SECRET" <> value "secret" <> showDefault)) <*> option auto (long "pool" <> short 'o' <> help "max connections in database pool" <> metavar "COUNT" <> value 10 <> showDefault) From 4dec445b82853f07532e946050e4bba604dfeb07 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Fri, 5 Feb 2016 09:30:42 -0800 Subject: [PATCH 5/6] Add example db connection string to usage --- src/PostgREST/Config.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PostgREST/Config.hs b/src/PostgREST/Config.hs index 8c60ef553..5aaccf9a7 100644 --- a/src/PostgREST/Config.hs +++ b/src/PostgREST/Config.hs @@ -47,7 +47,7 @@ data AppConfig = AppConfig { argParser :: Parser AppConfig argParser = AppConfig - <$> argument str (help "(REQUIRED) database connection string" <> metavar "DB_URL") + <$> argument str (help "(REQUIRED) database connection string, e.g. postgres://user:pass@host:port/db" <> metavar "DB_URL") <*> strOption (long "anonymous" <> short 'a' <> help "(REQUIRED) postgres role to use for non-authenticated requests" <> metavar "ROLE") <*> strOption (long "schema" <> short 's' <> help "schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault) <*> option auto (long "port" <> short 'p' <> help "port number on which to run HTTP server" <> metavar "PORT" <> value 3000 <> showDefault) From f65557573c314542979d95743d99a2d9bcd6beb9 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Fri, 5 Feb 2016 09:39:43 -0800 Subject: [PATCH 6/6] Match new config param order in tests --- test/SpecHelper.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SpecHelper.hs b/test/SpecHelper.hs index 886aaf1e0..22b80ee3c 100644 --- a/test/SpecHelper.hs +++ b/test/SpecHelper.hs @@ -30,7 +30,7 @@ dbString :: String dbString = "postgres://postgrest_test_authenticator@localhost:5432/postgrest_test" cfg :: String -> Maybe Integer -> AppConfig -cfg conStr = AppConfig conStr 3000 "postgrest_test_anonymous" "test" (secret "safe") 10 +cfg conStr = AppConfig conStr "postgrest_test_anonymous" "test" 3000 (secret "safe") 10 cfgDefault :: AppConfig cfgDefault = cfg dbString Nothing