README update

This commit is contained in:
Markus Thielen 2023-04-04 18:34:26 +02:00
parent 58b0bd2e8b
commit 2367d1308f

View File

@ -2,29 +2,49 @@
This project implements the *Hello World* of API-driven apps: a simple TODO app, built with Vue 3. 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, database schema, type maps etc. and scripts to run broker and dbproxy from within the `bbconf` directory.
## Recommended IDE Setup These files assume that you extracted the [basebox distribution](https://basebox.io/download) next to this repository's root.
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) Example:
Let's assume you create a `basebox` folder in your home directory, change into it, extract the basebox distribution archive in that folder and then clone the contents of this repository into the same folder:
``` sh
cd ~
mkdir basebox
cd basebox
tar xf 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
```
If you follow these steps, the scripts in `bbconf` will work out of the box.
## Installation ## Installation
To install this app, you need To install this app, you need
* npm, node.js * npm, node.js
* A PostgreSQL server, preferably on the local host (simpler) * A PostgreSQL server, preferably on the local host (simpler, but not suitable for production)
* basebox components (broker, dbproxy, bbc) * basebox components (broker, dbproxy, bbc)
* Keycloak * Keycloak
### PostgreSQL Preparation ### PostgreSQL Preparation
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 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). > 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 to create a user and a database for the todo app.
> 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. 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.
´´´sh ``` sh
# Under (Debian) Linux, switch to the postgres user first: # Under (Debian) Linux, switch to the postgres user first:
# sudo su postgres # sudo su postgres
createuser -DRP bb_todo # default password: basebox createuser -DRP bb_todo # default password: basebox
@ -38,31 +58,21 @@ Tell PostgreSQL that the `bb_todo` user connects to the database using md5 authe
local bb_todo bb_todo md5 local bb_todo bb_todo md5
``` ```
Make sure to add the line that starts with `local bb_todo...` under the commented header that starts with `# TYPE...`. PostgreSQL uses the first line that matches, so having the new line on top makes sure no other line overrides it.
Reload PostgreSQL config: Reload PostgreSQL config:
```sh ```sh
systemctl postgresql reload systemctl postgresql reload
``` ```
If PostgreSQL is older than version 13, you need to enable the crypto extension explicitly:
```sh
# Under (Debian) Linux, switch to the postgres user first:
# sudo su postgres
psql bb_todo
# At the # bb_todo prompt:
SELECT gen_random_uuid();
# If this prints a UUID, you're ok. If you get an error, do this:
CREATE EXTENSION pgcrypto;
# Might try the SELECT call again.
```
#### Database Schema #### Database Schema
This repository contains an already compiled SQL file that creates the database schema: This repository contains an already compiled SQL file that creates the database schema:
```sh ```sh
psql -U bb_todo bb_todo < bbconf/todo_datamodel.sql psql -U bb_todo bb_todo < bbconf/todo_datamodel.sql # Enter password when prompted.
``` ```
The database configuration and installation is now complete.