Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update README for SQLite #50

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 42 additions & 37 deletions plugins/notifications-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ It's backed by a relational database, so far tested with PostgreSQL.

## Getting started

### Prerequisites
The plugin uses a relational database to persist messages, it has been tested with the SQLite and PostgreSQL.

Upon backend's plugin start, the `backstage_plugin_notifications` database and its tables are created automatically.

### Optional: PostgreSQL

**To use the Backstage's default SQLite, no specific configuration is needed.**

Following steps describe requirements for PostgreSQL:

- Install [PostgresSQL DB](https://www.postgresql.org/download/)
- Configure Postgres for tcp/ip
Expand All @@ -28,7 +36,27 @@ host all postgres 127.0.0.1/32 pass
sudo systemctl enable --now postgresql.service
```

A new DB will be created: backstage_plugin_notifications
#### Backstage's configuration for PostgreSQL

If PostgreSQL is used, additional configuration in the in the `app-config.yaml` or `app-config.local.yaml` is needed. Example:

```
database:
client: pg
connection:
host: 127.0.0.1
port: 5432
user: postgres
password: your_secret
knexConfig:
pool:
min: 3
max: 12
acquireTimeoutMillis: 60000
idleTimeoutMillis: 60000
cache:
store: memory
```

### Add NPM dependency

Expand Down Expand Up @@ -90,29 +118,7 @@ apiRouter.use('/notifications', await notifications(notificationsEnv));

### Configure

In the `app-config.yaml` or `app-config.local.yaml`:

#### Database

```
database:
client: pg
connection:
host: 127.0.0.1
port: 5432
user: postgres
password: secret
knexConfig:
pool:
min: 3
max: 12
acquireTimeoutMillis: 60000
idleTimeoutMillis: 60000
cache:
store: memory
```

#### Other configuration (optional):
#### Optional: Plugin's configuration

If you have issues to create valid JWT tokens by an external caller, use following option to bypass the service-to-service configuration for them:

Expand All @@ -135,16 +141,16 @@ curl -X POST http://localhost:7007/api/notifications/notifications -H "Content-T

Notes:

- The `externalCallerSecret` is an workaround and will be probably replaced by proper use of JWT tokens.
- Sharing the same shared secret with the "auth.secret" option is not recommended
- The `externalCallerSecret` is an workaround, exclusive use of JWT tokens will probably be required in the future.
- Sharing the same shared secret with the "auth.secret" option is not recommended.

#### Authentication

Please refer https://backstage.io/docs/auth/ to set-up authentication.

The Notifications flows are based on the identity of the user.

All targetUsers, targetGroups or signed-in users receiving notifications must have corresponding entities created in the Catalog.
All `targetUsers`, `targetGroups`` or signed-in users receiving notifications must have corresponding entities created in the Catalog.
Refer https://backstage.io/docs/auth/identity-resolver for details.

For the purpose of development, there is `users.yaml` listing example data created.
Expand Down Expand Up @@ -220,15 +226,14 @@ User parameter is mandatory because it is needed for message status and filterin

Query parameters:

- pageSize. 0 means no paging.
- pageNumber. first page is 1. 0 means no paging.
- orderBy.
- orderByDirec. asc/desc
- user. name of user to retrieve notification for
- containsText. filter title and message containing this text (case insensitive)
- createdAfter. fetch notifications created after this point in time
- messageScope. all/user/system. fetch notifications intended for specific user or system notifications or both
- read. true/false (read/unread)
- `pageSize`. 0 means no paging.
- `pageNumber`. first page is 1. 0 means no paging.
- `orderBy`.
- `orderByDirec`. asc/desc
- `containsText`. filter title and message containing this text (case insensitive)
- `createdAfter`. fetch notifications created after this point in time
- `messageScope`. all/user/system. fetch notifications intended for specific user or system notifications or both
- `read`. true/false (read/unread)

Request:

Expand Down