From b9f0551c864f62cb9e26e2e459d8550a3e78d924 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sat, 16 Oct 2021 02:12:59 +0900 Subject: [PATCH] create hasura-rest --- hasura-rest/.gitignore | 1 + hasura-rest/config.yaml | 6 ++++ hasura-rest/docker-compose.yml | 34 +++++++++++++++++++ hasura-rest/metadata/actions.graphql | 0 hasura-rest/metadata/actions.yaml | 6 ++++ hasura-rest/metadata/allow_list.yaml | 1 + hasura-rest/metadata/cron_triggers.yaml | 1 + hasura-rest/metadata/databases/databases.yaml | 16 +++++++++ hasura-rest/metadata/query_collections.yaml | 1 + hasura-rest/metadata/remote_schemas.yaml | 1 + hasura-rest/metadata/version.yaml | 1 + .../default/1634309496485_init/up.sql | 7 ++++ 12 files changed, 75 insertions(+) create mode 100644 hasura-rest/.gitignore create mode 100644 hasura-rest/config.yaml create mode 100644 hasura-rest/docker-compose.yml create mode 100644 hasura-rest/metadata/actions.graphql create mode 100644 hasura-rest/metadata/actions.yaml create mode 100644 hasura-rest/metadata/allow_list.yaml create mode 100644 hasura-rest/metadata/cron_triggers.yaml create mode 100644 hasura-rest/metadata/databases/databases.yaml create mode 100644 hasura-rest/metadata/query_collections.yaml create mode 100644 hasura-rest/metadata/remote_schemas.yaml create mode 100644 hasura-rest/metadata/version.yaml create mode 100644 hasura-rest/migrations/default/1634309496485_init/up.sql diff --git a/hasura-rest/.gitignore b/hasura-rest/.gitignore new file mode 100644 index 0000000..f10862a --- /dev/null +++ b/hasura-rest/.gitignore @@ -0,0 +1 @@ +/.env diff --git a/hasura-rest/config.yaml b/hasura-rest/config.yaml new file mode 100644 index 0000000..725c800 --- /dev/null +++ b/hasura-rest/config.yaml @@ -0,0 +1,6 @@ +version: 3 +endpoint: http://localhost:8080 +metadata_directory: metadata +actions: + kind: synchronous + handler_webhook_baseurl: http://localhost:3000 diff --git a/hasura-rest/docker-compose.yml b/hasura-rest/docker-compose.yml new file mode 100644 index 0000000..d9ec27f --- /dev/null +++ b/hasura-rest/docker-compose.yml @@ -0,0 +1,34 @@ +version: "3" +services: + db: + image: postgres:13.4 + environment: + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + volumes: + - db_data:/var/lib/postgresql/data + hasura: + image: hasura/graphql-engine:v2.0.9.cli-migrations-v3 + depends_on: [db] + environment: + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres + HASURA_GRAPHQL_ENABLE_CONSOLE: "true" + HASURA_GRAPHQL_UNAUTHORIZED_ROLE: anonymous + HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET} + HASURA_GRAPHQL_JWT_SECRET: ${HASURA_GRAPHQL_JWT_SECRET} + volumes: + - ./migrations:/hasura-migrations + - ./metadata:/hasura-metadata + ports: + - "8080:8080" + postgrest: + image: postgrest/postgrest:v8.0.0 + depends_on: [db] + environment: + PGRST_DB_URI: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres + PGRST_DB_SCHEMA: public + PGRST_DB_ANON_ROLE: anonymous + PGRST_JWT_SECRET: ${JWT_SECRET} + ports: + - "3000:3000" +volumes: + db_data: diff --git a/hasura-rest/metadata/actions.graphql b/hasura-rest/metadata/actions.graphql new file mode 100644 index 0000000..e69de29 diff --git a/hasura-rest/metadata/actions.yaml b/hasura-rest/metadata/actions.yaml new file mode 100644 index 0000000..1edb4c2 --- /dev/null +++ b/hasura-rest/metadata/actions.yaml @@ -0,0 +1,6 @@ +actions: [] +custom_types: + enums: [] + input_objects: [] + objects: [] + scalars: [] diff --git a/hasura-rest/metadata/allow_list.yaml b/hasura-rest/metadata/allow_list.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura-rest/metadata/allow_list.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura-rest/metadata/cron_triggers.yaml b/hasura-rest/metadata/cron_triggers.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura-rest/metadata/cron_triggers.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura-rest/metadata/databases/databases.yaml b/hasura-rest/metadata/databases/databases.yaml new file mode 100644 index 0000000..8360dbb --- /dev/null +++ b/hasura-rest/metadata/databases/databases.yaml @@ -0,0 +1,16 @@ +- name: default + kind: postgres + configuration: + connection_info: + database_url: + from_env: HASURA_GRAPHQL_DATABASE_URL + tables: + - table: + schema: public + name: users + insert_permissions: + - role: anonymous + permission: + check: {} + columns: + - name diff --git a/hasura-rest/metadata/query_collections.yaml b/hasura-rest/metadata/query_collections.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura-rest/metadata/query_collections.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura-rest/metadata/remote_schemas.yaml b/hasura-rest/metadata/remote_schemas.yaml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/hasura-rest/metadata/remote_schemas.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura-rest/metadata/version.yaml b/hasura-rest/metadata/version.yaml new file mode 100644 index 0000000..0a70aff --- /dev/null +++ b/hasura-rest/metadata/version.yaml @@ -0,0 +1 @@ +version: 3 diff --git a/hasura-rest/migrations/default/1634309496485_init/up.sql b/hasura-rest/migrations/default/1634309496485_init/up.sql new file mode 100644 index 0000000..7f6af31 --- /dev/null +++ b/hasura-rest/migrations/default/1634309496485_init/up.sql @@ -0,0 +1,7 @@ +CREATE ROLE anonymous; +ALTER ROLE anonymous SET statement_timeout = '1s'; +CREATE TABLE users ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name TEXT +); +GRANT INSERT (name) ON users TO anonymous;