first commit; basebox conf for testing
This commit is contained in:
commit
c5e4cd72f1
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
.#*
|
||||
|
32
bbconf/bb_todo_datamodel.sql
Normal file
32
bbconf/bb_todo_datamodel.sql
Normal file
@ -0,0 +1,32 @@
|
||||
CREATE TABLE "List" (
|
||||
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
|
||||
"title" VARCHAR NOT NULL,
|
||||
"user.username" VARCHAR NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE "Task" (
|
||||
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
|
||||
"title" VARCHAR NOT NULL,
|
||||
"description" VARCHAR,
|
||||
"completed" BOOLEAN NOT NULL,
|
||||
"user.username" VARCHAR NOT NULL,
|
||||
"list.id" UUID NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE "User" (
|
||||
"username" VARCHAR NOT NULL,
|
||||
"name" VARCHAR
|
||||
);
|
||||
|
||||
ALTER TABLE "List" ADD PRIMARY KEY ("id");
|
||||
|
||||
ALTER TABLE "Task" ADD PRIMARY KEY ("id");
|
||||
|
||||
ALTER TABLE "User" ADD PRIMARY KEY ("username");
|
||||
|
||||
ALTER TABLE "List" ADD CONSTRAINT fk_list_1 FOREIGN KEY ("user.username") REFERENCES "User" ("username");
|
||||
|
||||
ALTER TABLE "Task" ADD CONSTRAINT fk_task_2 FOREIGN KEY ("user.username") REFERENCES "User" ("username");
|
||||
|
||||
ALTER TABLE "Task" ADD CONSTRAINT fk_task_3 FOREIGN KEY ("list.id") REFERENCES "List" ("id");
|
||||
|
59
bbconf/bb_todo_resolvers.toml
Normal file
59
bbconf/bb_todo_resolvers.toml
Normal file
@ -0,0 +1,59 @@
|
||||
[resolvers.updateTask]
|
||||
operation_name = "updateTask"
|
||||
|
||||
[resolvers.updateTask.resolver]
|
||||
command_type = "SQLUpdate"
|
||||
columns = []
|
||||
tables = []
|
||||
where_clauses = [["Task", "id", "= '$id'"]]
|
||||
join_clauses = []
|
||||
modify_table = ["Task", ""]
|
||||
modify_values = [["title", "'$title'"], ["description", "'$description'"], ["completed", "$completed"], ["list.id", "'$list.$id'"]]
|
||||
|
||||
[resolvers.createList]
|
||||
operation_name = "createList"
|
||||
|
||||
[resolvers.createList.resolver]
|
||||
command_type = "SQLInsert"
|
||||
columns = []
|
||||
tables = []
|
||||
where_clauses = []
|
||||
join_clauses = []
|
||||
modify_table = ["List", ""]
|
||||
modify_values = [["title", "'$title'"], ["user.username", "'$user.$username'"]]
|
||||
|
||||
[resolvers.getUser]
|
||||
operation_name = "getUser"
|
||||
|
||||
[resolvers.getUser.resolver]
|
||||
command_type = "SQLSelect"
|
||||
columns = []
|
||||
tables = [["User", ""]]
|
||||
where_clauses = [["User", "username", "= '$username'"]]
|
||||
join_clauses = []
|
||||
modify_table = ["", ""]
|
||||
modify_values = []
|
||||
|
||||
[resolvers.createTask]
|
||||
operation_name = "createTask"
|
||||
|
||||
[resolvers.createTask.resolver]
|
||||
command_type = "SQLInsert"
|
||||
columns = []
|
||||
tables = []
|
||||
where_clauses = []
|
||||
join_clauses = []
|
||||
modify_table = ["Task", ""]
|
||||
modify_values = [["title", "'$title'"], ["description", "'$description'"], ["completed", "$completed"], ["list.id", "'$list.$id'"], ["user.username", "'$user.$username'"]]
|
||||
|
||||
[resolvers.deleteTask]
|
||||
operation_name = "deleteTask"
|
||||
|
||||
[resolvers.deleteTask.resolver]
|
||||
command_type = "SQLDelete"
|
||||
columns = []
|
||||
tables = []
|
||||
where_clauses = [["Task", "id", "= '$id'"]]
|
||||
join_clauses = []
|
||||
modify_table = ["Task", ""]
|
||||
modify_values = []
|
200
bbconf/bb_todo_typemap.json
Normal file
200
bbconf/bb_todo_typemap.json
Normal file
@ -0,0 +1,200 @@
|
||||
{
|
||||
"type_list": [
|
||||
{
|
||||
"Object": {
|
||||
"gql_object": "List",
|
||||
"sql_table": "List"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ObjectField": {
|
||||
"gql_object": "List",
|
||||
"gql_field": "id",
|
||||
"sql_table": "List",
|
||||
"sql_column": "id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ObjectField": {
|
||||
"gql_object": "List",
|
||||
"gql_field": "title",
|
||||
"sql_table": "List",
|
||||
"sql_column": "title"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Object": {
|
||||
"gql_object": "Task",
|
||||
"sql_table": "Task"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ObjectField": {
|
||||
"gql_object": "Task",
|
||||
"gql_field": "id",
|
||||
"sql_table": "Task",
|
||||
"sql_column": "id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ObjectField": {
|
||||
"gql_object": "Task",
|
||||
"gql_field": "title",
|
||||
"sql_table": "Task",
|
||||
"sql_column": "title"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ObjectField": {
|
||||
"gql_object": "Task",
|
||||
"gql_field": "description",
|
||||
"sql_table": "Task",
|
||||
"sql_column": "description"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ObjectField": {
|
||||
"gql_object": "Task",
|
||||
"gql_field": "completed",
|
||||
"sql_table": "Task",
|
||||
"sql_column": "completed"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Object": {
|
||||
"gql_object": "User",
|
||||
"sql_table": "User"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ObjectField": {
|
||||
"gql_object": "User",
|
||||
"gql_field": "username",
|
||||
"sql_table": "User",
|
||||
"sql_column": "username"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ObjectField": {
|
||||
"gql_object": "User",
|
||||
"gql_field": "name",
|
||||
"sql_table": "User",
|
||||
"sql_column": "name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Join": {
|
||||
"gql_object": "List",
|
||||
"gql_field": "user",
|
||||
"gql_type": "User",
|
||||
"sql_join_type": {
|
||||
"OneToMany": {
|
||||
"sql_table_of_object": "List",
|
||||
"sql_table_of_field": "User",
|
||||
"sql_mapped_columns": [
|
||||
[
|
||||
"user.username",
|
||||
"username"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Join": {
|
||||
"gql_object": "User",
|
||||
"gql_field": "lists",
|
||||
"gql_type": "List",
|
||||
"sql_join_type": {
|
||||
"ManyToOne": {
|
||||
"sql_table_of_object": "User",
|
||||
"sql_table_of_field": "List",
|
||||
"sql_mapped_columns": [
|
||||
[
|
||||
"username",
|
||||
"user.username"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Join": {
|
||||
"gql_object": "Task",
|
||||
"gql_field": "user",
|
||||
"gql_type": "User",
|
||||
"sql_join_type": {
|
||||
"OneToMany": {
|
||||
"sql_table_of_object": "Task",
|
||||
"sql_table_of_field": "User",
|
||||
"sql_mapped_columns": [
|
||||
[
|
||||
"user.username",
|
||||
"username"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Join": {
|
||||
"gql_object": "User",
|
||||
"gql_field": "tasks",
|
||||
"gql_type": "Task",
|
||||
"sql_join_type": {
|
||||
"ManyToOne": {
|
||||
"sql_table_of_object": "User",
|
||||
"sql_table_of_field": "Task",
|
||||
"sql_mapped_columns": [
|
||||
[
|
||||
"username",
|
||||
"user.username"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Join": {
|
||||
"gql_object": "Task",
|
||||
"gql_field": "list",
|
||||
"gql_type": "List",
|
||||
"sql_join_type": {
|
||||
"OneToMany": {
|
||||
"sql_table_of_object": "Task",
|
||||
"sql_table_of_field": "List",
|
||||
"sql_mapped_columns": [
|
||||
[
|
||||
"list.id",
|
||||
"id"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Join": {
|
||||
"gql_object": "List",
|
||||
"gql_field": "tasks",
|
||||
"gql_type": "Task",
|
||||
"sql_join_type": {
|
||||
"ManyToOne": {
|
||||
"sql_table_of_object": "List",
|
||||
"sql_table_of_field": "Task",
|
||||
"sql_mapped_columns": [
|
||||
[
|
||||
"id",
|
||||
"list.id"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
73
bbconf/broker-config.toml
Normal file
73
bbconf/broker-config.toml
Normal file
@ -0,0 +1,73 @@
|
||||
[broker]
|
||||
# log level; can be error, warn, info, debug, trace
|
||||
log_level = "info"
|
||||
|
||||
[graphql]
|
||||
# path and file name to GraphQL schema file
|
||||
schema_file = "todo5_schema.graphql"
|
||||
|
||||
[proxy]
|
||||
# host name or IP of basebox DB proxy
|
||||
host = "localhost"
|
||||
port = 8081
|
||||
# Whether to use http or https to connect to the proxy
|
||||
tls = false
|
||||
|
||||
[server]
|
||||
# Host name of the broker (GraphQL server)
|
||||
host = "127.0.0.1"
|
||||
|
||||
# Port number; default is 80 for http, 443 for https
|
||||
port = 8080
|
||||
|
||||
# number of HTTP server threads to spawn; default is one per CPU core
|
||||
workers = 2
|
||||
|
||||
# Path and file name of TLS/SSL key file
|
||||
# cert_key_file = "/path/to/key.pem"
|
||||
|
||||
# Path and file name of TLS certificate (chain) file
|
||||
# cert_file = "/path/to/cert.pem"
|
||||
|
||||
[oauth2]
|
||||
# OAuth2 client id
|
||||
client_id = "todo-app"
|
||||
|
||||
# Oauth2 Realm
|
||||
realm = "todo"
|
||||
|
||||
# OAuth2 client secret
|
||||
client_secret = "SLnMUb4JArLs5LtzoqcQu0rg9PpgLtsN"
|
||||
|
||||
# Base URL to the identity provider (OAuth2/OpenID Connect server, e.g. Keycloak)
|
||||
idp_url = "https://kcdev.basebox.health:8443"
|
||||
|
||||
# OpenID Connect scope; default is "openid profile email"
|
||||
scope = "openid profile email"
|
||||
|
||||
# Optional base URL for OAuth2 URLs, e.g. "https://domain.tld/auth"
|
||||
# If omitted, it will be derived from the fields in the [server] section.
|
||||
# base_url = "http://localhost:8080"
|
||||
|
||||
# Will be appended to `base_url` to form the OAuth2 callback URL
|
||||
redirect_path = "/oauth/callback"
|
||||
|
||||
# Set to true to get a user's additional claims from OAuth2
|
||||
user_info_additional_claims_required = true
|
||||
|
||||
# On successful login (auth code flow complete), the browser can optionally
|
||||
# be redirected to the application URL.
|
||||
# If this is unset, the browser gets an empty 200 response on successful
|
||||
# authorization code flow completion.
|
||||
client_app_url = "http://127.0.0.1:8080/_test/ping/"
|
||||
|
||||
[business_logic_layer]
|
||||
business_logic_layer_enabled = false
|
||||
python_module_path = "/path/to/python/module"
|
||||
python_module_name = "mymodule"
|
||||
|
||||
[business_logic_layer.pre_definition]
|
||||
all = ["query"]
|
||||
query = ["getExercises", "getExercise"]
|
||||
mutation = ["createExercise", "updateExercise", "deleteExercise"]
|
||||
fragment = []
|
3
bbconf/broker.sh
Executable file
3
bbconf/broker.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
# Run basebox broker from the samples/toodo/bbconf directory
|
||||
PYO3_PYTHON=python3.10 cargo run --manifest-path ../../../broker/Cargo.toml -- -c broker-config.toml
|
53
bbconf/dbproxy-config.toml
Normal file
53
bbconf/dbproxy-config.toml
Normal file
@ -0,0 +1,53 @@
|
||||
[generic]
|
||||
# log level; can be error, warn, info, debug, trace
|
||||
log_level = "info"
|
||||
|
||||
[idp_config]
|
||||
# URL of IdP's discovery endpoint. If not set, the URL is made up by appending
|
||||
# ".well-known/openid-configuration" to the id_token_validation.iss field.
|
||||
discovery_url = "https://kcdev.basebox.health:8443/realms/todo/.well-known/openid-configuration"
|
||||
# URL of IdP's public keystore. If set, the discovery endpoint is not used at all.
|
||||
jwks_url = "https://kcdev.basebox.health:8443/realms/todo/protocol/openid-connect/certs"
|
||||
|
||||
[id_token_validation]
|
||||
# Incoming ID tokens are validated using, among other, the following fields.
|
||||
# Contents of 'iss' field, usually the URL of the authetnication realm
|
||||
iss = "https://kcdev.basebox.health/realms/todo"
|
||||
# Contents of 'aud' field, aka the OpenID connect client ID
|
||||
aud = "test-1"
|
||||
|
||||
[graphql]
|
||||
# path and file name to GraphQL schema file
|
||||
schema_file = "todo5_schema.graphql"
|
||||
# Path and file name of the resolver map file
|
||||
resolver_map_file = "bb_todo_resolvers.toml"
|
||||
# Path and file name of the type map file
|
||||
type_map_file = "bb_todo_typemap.json"
|
||||
|
||||
[database]
|
||||
# Type of database; currently, only "postgres" is suppoerted
|
||||
db_type = "postgres"
|
||||
# The host where the DB server is runnung
|
||||
host = "localhost"
|
||||
# Port the DB server is listening at
|
||||
port = 5432
|
||||
# Database name
|
||||
db_name = "bb_todo"
|
||||
username = "bb_todo"
|
||||
password = "basebox"
|
||||
|
||||
[server]
|
||||
# Host name of (this) proxy server
|
||||
host = "localhost"
|
||||
|
||||
# Port number; default is 80 for http, 443 for https
|
||||
port = 8081
|
||||
|
||||
# number of HTTP server threads to spawn; default is one per CPU core
|
||||
workers = 2
|
||||
|
||||
# Path and file name of TLS/SSL key file
|
||||
# cert_key_file = "/path/to/key.pem"
|
||||
|
||||
# Path and file name of TLS certificate (chain) file
|
||||
# cert_file = "/path/to/cert.pem"
|
3
bbconf/dbproxy.sh
Executable file
3
bbconf/dbproxy.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
# Run basebox dbproxy from the samples/toodo/bbconf directory
|
||||
cargo run --manifest-path ../../../dbproxy/Cargo.toml -- -c dbproxy-config.toml
|
67
bbconf/todo5_schema.graphql
Normal file
67
bbconf/todo5_schema.graphql
Normal file
@ -0,0 +1,67 @@
|
||||
type List {
|
||||
id: ID!
|
||||
title: String!
|
||||
tasks: [Task]
|
||||
user: User!
|
||||
}
|
||||
|
||||
"""
|
||||
Task or todo item.
|
||||
"""
|
||||
type Task {
|
||||
id: ID!
|
||||
title: String!
|
||||
description: String,
|
||||
completed: Boolean!
|
||||
user: User!
|
||||
list: List!
|
||||
}
|
||||
|
||||
"""
|
||||
User type; owner of lists and tasks
|
||||
"""
|
||||
type User {
|
||||
username: String! @bb_primaryKey
|
||||
name: String
|
||||
tasks: [Task]
|
||||
lists: [List]
|
||||
}
|
||||
|
||||
|
||||
type Query {
|
||||
|
||||
"""
|
||||
Get a user, this will be used to get the current user as well as the user's lists and tasks.
|
||||
"""
|
||||
getUser(
|
||||
username: String!
|
||||
): User @bb_resolver(_type: select, _object: User, _filter: { username: { _eq: "$username" } })
|
||||
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
|
||||
createList(
|
||||
title: String!
|
||||
user: User! # username needs to be specified as it's non-nullable
|
||||
): List @bb_resolver(_type: insert, _object: List, _fields: { title: "$title", user: "$user" })
|
||||
|
||||
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
|
||||
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" })
|
||||
|
||||
updateTask(
|
||||
id: ID!,
|
||||
title: String,
|
||||
description: String,
|
||||
completed: Boolean,
|
||||
list: List
|
||||
): Task @bb_resolver(_type: update, _object: Task, _filter: { id: { _eq: "$id" } }, _fields: { title: "$title", description: "$description", completed: "$completed", list: "$list" })
|
||||
|
||||
deleteTask(id: ID!): Task @bb_resolver(_type: delete, _object: Task, _filter: { id: { _eq: "$id" } })
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user