From 14761fa3e5b993890a9c243e1373a93027e52028 Mon Sep 17 00:00:00 2001 From: Markus Thielen Date: Tue, 4 Apr 2023 20:02:06 +0200 Subject: [PATCH] updated shell scripts to use binaries --- README.md | 28 +++++++++++++++------------- bbconf/broker.sh | 2 +- bbconf/compile.sh | 2 +- bbconf/dbproxy.sh | 2 +- bbconf/install-config.toml | 18 ------------------ bbconf/todo_schema.graphql | 6 +++--- 6 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 bbconf/install-config.toml diff --git a/README.md b/README.md index 7b86650..855fab3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This project implements the *Hello World* of API-driven apps: a simple TODO app, built with Vue 3. -The `bbconf` folder contains basebox config files, database schema, type maps etc. and scripts to run broker and dbproxy from within the `bbconf` directory. +The `bbconf` folder contains basebox config files, GraphQL schema, precompiled database schema, type maps etc. and scripts to run broker and dbproxy from within the `bbconf` directory. These files assume that you extracted the [basebox distribution](https://basebox.io/download) next to this repository's root. @@ -13,7 +13,7 @@ Let's assume you create a `basebox` folder in your home directory, change into i cd ~ mkdir basebox cd basebox -tar xf basebox-version-arch.tgz # adopt this command to the basebox distribution archive you downloaded +tar xzf basebox-version-arch.tgz # adopt this command to the basebox distribution archive you downloaded git clone --single-branch --depth 1 https://gitea.basebox.health/samples/vue-todo.git ``` @@ -30,19 +30,13 @@ To install this app, you need ### PostgreSQL Preparation -> The following guide assumes you are installing under Debian or Ubuntu Linux; if you are on a Mac, please see our [PostgreSQL Primer](https://docs.basebox.io/getting-started/postgresql/) for some hints. +> You need a PostgreSQL database to run this app. You can read detailed instructions on how to +> install PostgreSQL and create a test database at our [PostgreSQL Primer](https://docs.basebox.io/getting-started/postgresql/) page. -You need to create a user and a database for the todo app. +The recommended way to run basebox is to have a dedicated Unix user for basebox that authenticates to PostgreSQL using Peer authentication. This way, no password for the DB user has to be stored anywhere. +However, to keep things simple for the test app, we create a local user that authenticates to the database server via password (md5). -> Please note: -> -> The recommended way to run basebox is to have a dedicated Unix user for dbproxy that -> authenticates to PostgreSQL using Peer authentication. This way, no password for the -> DB user has to be stored anywhere. The Unix user's name must match the name of the -> PostgreSQL user. For more info, see the basebox installation instructions and -> [PostgreSQL documentation](https://www.postgresql.org/docs/current/auth-peer.html). - -For simplicity's sake, we are using a normal PostgreSQL user that authenticates using md5 authentication, thus requires a password, which is set in the dbproxy configuration file. +Let's create a PostgreSQL user and database for the TODO app: ``` sh # Under (Debian) Linux, switch to the postgres user first: @@ -76,3 +70,11 @@ psql -U bb_todo bb_todo < bbconf/todo_datamodel.sql # Enter password when promp ``` The database configuration and installation is now complete. + +If you're curious, you can recompile the GraphQL schema like so: + +```sh +bin/bbconf --prefix=bb_todo -f todo_schema.graphql -o bbconf +``` + + diff --git a/bbconf/broker.sh b/bbconf/broker.sh index 6957ba9..7c32642 100755 --- a/bbconf/broker.sh +++ b/bbconf/broker.sh @@ -1,3 +1,3 @@ #!/bin/sh # Run basebox broker from the samples/toodo/bbconf directory -PYO3_PYTHON=python3 cargo run --manifest-path ../../../broker/Cargo.toml -- -c broker-config.toml +../../bin/broker -c broker-config.toml diff --git a/bbconf/compile.sh b/bbconf/compile.sh index 06957e0..bbb9842 100755 --- a/bbconf/compile.sh +++ b/bbconf/compile.sh @@ -2,4 +2,4 @@ # # Compile the todo schema. # -cargo run --manifest-path=../../../bbc/Cargo.toml -- --prefix=bb_todo -f todo_schema.graphql +../../bin/bbc --prefix=bb_todo -f todo_schema.graphql diff --git a/bbconf/dbproxy.sh b/bbconf/dbproxy.sh index 2b15ded..95a4dd3 100755 --- a/bbconf/dbproxy.sh +++ b/bbconf/dbproxy.sh @@ -1,3 +1,3 @@ #!/bin/sh # Run basebox dbproxy from the samples/toodo/bbconf directory -cargo run --manifest-path ../../../dbproxy/Cargo.toml -- -c dbproxy-config.toml +../../bin/dbproxy -c dbproxy-config.toml diff --git a/bbconf/install-config.toml b/bbconf/install-config.toml deleted file mode 100644 index 718ebd7..0000000 --- a/bbconf/install-config.toml +++ /dev/null @@ -1,18 +0,0 @@ -# Sample toml file; for testing only - -[generic] -# the name of the project -project_name = "bb_todo" -# the folder where the generated files will be placed. If not specifed, the project name will be -# used to create a folder by that name in the current directory. Note that the folder must not exist -# yet in order to make ensure that an existing installation will not be overwritten by accident. -output = "output" - -[log] -# log level; can be off, error, warn, info, debug, trace -log_level = "info" - -[graphql] -schema = "todo_schema.graphql" - -[database] diff --git a/bbconf/todo_schema.graphql b/bbconf/todo_schema.graphql index 579c263..6ea8133 100644 --- a/bbconf/todo_schema.graphql +++ b/bbconf/todo_schema.graphql @@ -39,7 +39,7 @@ type Query { getUser( username: String! ): User @bb_resolver(_type: select, _object: User, _filter: { username: { _eq: "$username" } }) - + } type Mutation { @@ -64,8 +64,8 @@ type Mutation { createTask( title: String!, description: String, - completed: Boolean!, # default not implemented yet, this needs to be added as it's non-nullable - list: List! # list needs to be specified as it's non-nullable + completed: Boolean!, # default not implemented yet, this needs to be added as it's non-nullable + list: List! # list needs to be specified as it's non-nullable user: User! # username needs to be specified as it's non-nullable ): Task @bb_resolver(_type: insert, _object: Task, _fields: { title: "$title", description: "$description", completed: "$completed", list: "$list", user: "$user" })