From 29e10622e53b3bc6daebbe68991122638f405e0b Mon Sep 17 00:00:00 2001 From: Keisuke Kan <9renpoto@gmail.com> Date: Tue, 17 Nov 2020 21:39:31 +0900 Subject: [PATCH 1/3] feat: hasura --- docker-compose.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6b633a86..97e29608 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,25 @@ -version: '3' - +version: '3.6' services: - db: - image: postgres:10-alpine + postgres: + image: postgres:12-alpine + volumes: + - db_data:/var/lib/postgresql/data environment: - POSTGRES_PASSWORD: password + POSTGRES_PASSWORD: postgrespassword + graphql-engine: + image: hasura/graphql-engine:v1.3.2 ports: - - '15432:5432' + - '8080:8080' + depends_on: + - 'postgres' + environment: + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres + ## enable the console served by server + HASURA_GRAPHQL_ENABLE_CONSOLE: 'true' # set to "false" to disable console + ## enable debugging mode. It is recommended to disable this in production + HASURA_GRAPHQL_DEV_MODE: 'true' + HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log + ## uncomment next line to set an admin secret + # HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey +volumes: + db_data: From dfa3b1f74bd2d459d5d1154ce76c6f26bcf2308e Mon Sep 17 00:00:00 2001 From: Keisuke Kan <9renpoto@gmail.com> Date: Tue, 17 Nov 2020 22:41:35 +0900 Subject: [PATCH 2/3] feat: hasura --- .envrc.tmpl | 5 ++++ apps/core/src/config/database.ts | 4 +++ apps/hasura/config.yaml | 6 ++++ apps/hasura/metadata/actions.graphql | 0 apps/hasura/metadata/actions.yaml | 6 ++++ apps/hasura/metadata/allow_list.yaml | 1 + apps/hasura/metadata/cron_triggers.yaml | 1 + apps/hasura/metadata/functions.yaml | 1 + apps/hasura/metadata/query_collections.yaml | 1 + apps/hasura/metadata/remote_schemas.yaml | 1 + apps/hasura/metadata/tables.yaml | 1 + apps/hasura/metadata/version.yaml | 1 + .../migrations/1605620280685_init/up.sql | 0 apps/hasura/package.json | 6 ++++ db/init.sql | 2 ++ docker-compose.yml | 14 ++++----- package.json | 3 ++ packages/variables/package.json | 3 +- yarn.lock | 29 ++++++++++++++++++- 19 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 .envrc.tmpl create mode 100644 apps/hasura/config.yaml create mode 100644 apps/hasura/metadata/actions.graphql create mode 100644 apps/hasura/metadata/actions.yaml create mode 100644 apps/hasura/metadata/allow_list.yaml create mode 100644 apps/hasura/metadata/cron_triggers.yaml create mode 100644 apps/hasura/metadata/functions.yaml create mode 100644 apps/hasura/metadata/query_collections.yaml create mode 100644 apps/hasura/metadata/remote_schemas.yaml create mode 100644 apps/hasura/metadata/tables.yaml create mode 100644 apps/hasura/metadata/version.yaml create mode 100644 apps/hasura/migrations/1605620280685_init/up.sql create mode 100644 apps/hasura/package.json create mode 100644 db/init.sql diff --git a/.envrc.tmpl b/.envrc.tmpl new file mode 100644 index 00000000..429923f3 --- /dev/null +++ b/.envrc.tmpl @@ -0,0 +1,5 @@ +export POSTGRES_PASSWORD=password +export DATABASE_HOST="127.0.0.1" +export DATABASE_PORT="15432" +export POSTGRES_USER="postgres" +export POSTGRES_DB="postgres" diff --git a/apps/core/src/config/database.ts b/apps/core/src/config/database.ts index 4f8ce11b..9e90fe22 100644 --- a/apps/core/src/config/database.ts +++ b/apps/core/src/config/database.ts @@ -9,6 +9,10 @@ export const config: ConnectionOptions = { username: process.env.POSTGRES_USER, password: process.env.POSTGRES_PASSWORD, database: process.env.POSTGRES_DB, + port: + typeof process.env.DATABASE_PORT === 'undefined' + ? 5432 + : Number(process.env.DATABASE_PORT), entities: [join(__dirname, '../**/*.entity.[t|j]s')], extra: process.env.NODE_ENV === 'production' && { socketPath: process.env.DATABASE_HOST, diff --git a/apps/hasura/config.yaml b/apps/hasura/config.yaml new file mode 100644 index 00000000..6ddf586e --- /dev/null +++ b/apps/hasura/config.yaml @@ -0,0 +1,6 @@ +version: 2 +endpoint: http://localhost:8080 +metadata_directory: metadata +actions: + kind: synchronous + handler_webhook_baseurl: http://localhost:3000 diff --git a/apps/hasura/metadata/actions.graphql b/apps/hasura/metadata/actions.graphql new file mode 100644 index 00000000..e69de29b diff --git a/apps/hasura/metadata/actions.yaml b/apps/hasura/metadata/actions.yaml new file mode 100644 index 00000000..1edb4c2f --- /dev/null +++ b/apps/hasura/metadata/actions.yaml @@ -0,0 +1,6 @@ +actions: [] +custom_types: + enums: [] + input_objects: [] + objects: [] + scalars: [] diff --git a/apps/hasura/metadata/allow_list.yaml b/apps/hasura/metadata/allow_list.yaml new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/apps/hasura/metadata/allow_list.yaml @@ -0,0 +1 @@ +[] diff --git a/apps/hasura/metadata/cron_triggers.yaml b/apps/hasura/metadata/cron_triggers.yaml new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/apps/hasura/metadata/cron_triggers.yaml @@ -0,0 +1 @@ +[] diff --git a/apps/hasura/metadata/functions.yaml b/apps/hasura/metadata/functions.yaml new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/apps/hasura/metadata/functions.yaml @@ -0,0 +1 @@ +[] diff --git a/apps/hasura/metadata/query_collections.yaml b/apps/hasura/metadata/query_collections.yaml new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/apps/hasura/metadata/query_collections.yaml @@ -0,0 +1 @@ +[] diff --git a/apps/hasura/metadata/remote_schemas.yaml b/apps/hasura/metadata/remote_schemas.yaml new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/apps/hasura/metadata/remote_schemas.yaml @@ -0,0 +1 @@ +[] diff --git a/apps/hasura/metadata/tables.yaml b/apps/hasura/metadata/tables.yaml new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/apps/hasura/metadata/tables.yaml @@ -0,0 +1 @@ +[] diff --git a/apps/hasura/metadata/version.yaml b/apps/hasura/metadata/version.yaml new file mode 100644 index 00000000..22817d2a --- /dev/null +++ b/apps/hasura/metadata/version.yaml @@ -0,0 +1 @@ +version: 2 diff --git a/apps/hasura/migrations/1605620280685_init/up.sql b/apps/hasura/migrations/1605620280685_init/up.sql new file mode 100644 index 00000000..e69de29b diff --git a/apps/hasura/package.json b/apps/hasura/package.json new file mode 100644 index 00000000..27e290b4 --- /dev/null +++ b/apps/hasura/package.json @@ -0,0 +1,6 @@ +{ + "name": "@9renpoto/hasura", + "version": "1.0.0", + "license": "MIT", + "private": true +} diff --git a/db/init.sql b/db/init.sql new file mode 100644 index 00000000..e468dcc6 --- /dev/null +++ b/db/init.sql @@ -0,0 +1,2 @@ +set client_encoding = 'UTF8'; +create database hasura; diff --git a/docker-compose.yml b/docker-compose.yml index 97e29608..201945d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,21 @@ version: '3.6' services: - postgres: + db: image: postgres:12-alpine volumes: - - db_data:/var/lib/postgresql/data + - ./db:/docker-entrypoint-initdb.d environment: - POSTGRES_PASSWORD: postgrespassword + POSTGRES_PASSWORD: password + ports: + - '15432:5432' graphql-engine: image: hasura/graphql-engine:v1.3.2 ports: - '8080:8080' depends_on: - - 'postgres' + - 'db' environment: - HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:password@db:5432/hasura ## enable the console served by server HASURA_GRAPHQL_ENABLE_CONSOLE: 'true' # set to "false" to disable console ## enable debugging mode. It is recommended to disable this in production @@ -21,5 +23,3 @@ services: HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log ## uncomment next line to set an admin secret # HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey -volumes: - db_data: diff --git a/package.json b/package.json index 9bba095b..2860b9ef 100644 --- a/package.json +++ b/package.json @@ -13,15 +13,18 @@ "lint:pkg": "lerna run lint --parallel", "lint:prettier": "prettier --check './{packages,apps}/**/*.{js,jsx,ts,tsx}'", "release": "lerna exec --no-bail -- 'can-npm-publish && npm publish --registry=\"https://registry.npmjs.org/\"'", + "hasura": "yarn workspace @9renpoto/hasura hasura", "test": "lerna run test -- -w 1" }, "devDependencies": { "@9renpoto/eslint-config-typescript": "7.2.0", "@9renpoto/textlint-config-ja": "7.2.0", + "@9renpoto/tsconfig": "^7.2.0", "@types/faker": "5.1.4", "@types/jest": "26.0.15", "eslint": "7.13.0", "faker": "5.1.0", + "hasura-cli": "^1.3.2", "husky": "4.3.0", "jest": "26.6.3", "lcov-result-merger": "3.1.0", diff --git a/packages/variables/package.json b/packages/variables/package.json index 2e31cc9d..b1fe72e8 100644 --- a/packages/variables/package.json +++ b/packages/variables/package.json @@ -5,7 +5,8 @@ "main": "lib/index.js", "scripts": { "build": "tsc -p .", - "clean": "rimraf lib" + "clean": "rimraf lib", + "prebuild": "npm run clean" }, "files": [ "lib" diff --git a/yarn.lock b/yarn.lock index ce8c79b9..563519fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -41,6 +41,11 @@ textlint-rule-preset-ja-spacing "^2.0.1" textlint-rule-preset-jtf-style "^2.3.4" +"@9renpoto/tsconfig@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@9renpoto/tsconfig/-/tsconfig-7.2.0.tgz#1bcc8c684f7eef409eba56b5c1cbb4cfdd99b60e" + integrity sha512-dJXmVY+0GY9FTKhPpYIowRib+FSQuUD109T/tXb0Av17dK/g4a3whc/GU32804ySKLPjhOCLsXVcaea9ysVLTA== + "@angular-devkit/core@11.0.1": version "11.0.1" resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-11.0.1.tgz#7125b07ac7d66a8fdaaf612a3b757817d23b8107" @@ -3536,6 +3541,13 @@ axios@0.21.0: dependencies: follow-redirects "^1.10.0" +axios@^0.19.0: + version "0.19.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27" + integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA== + dependencies: + follow-redirects "1.5.10" + babel-jest@^26.6.3: version "26.6.3" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.6.3.tgz#d87d25cb0037577a0c89f82e5755c5d293c01056" @@ -4682,7 +4694,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0: +debug@3.1.0, debug@=3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== @@ -5762,6 +5774,13 @@ flush-write-stream@^1.0.0, flush-write-stream@^1.0.2: inherits "^2.0.3" readable-stream "^2.3.6" +follow-redirects@1.5.10: + version "1.5.10" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" + integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ== + dependencies: + debug "=3.1.0" + follow-redirects@^1.10.0: version "1.13.0" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db" @@ -6391,6 +6410,14 @@ hastscript@^5.0.0: property-information "^5.0.0" space-separated-tokens "^1.0.0" +hasura-cli@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/hasura-cli/-/hasura-cli-1.3.2.tgz#e38ae1167976cd588718ce66c1330a7f694a17c7" + integrity sha512-x+f/fpjJyI47b0KWvOKQqTNMKLAVXaFEN63EPz4kAjqTSQD/hinmWDW4YSDBWnCUtaQHTyIS5hsLzxw9yWFA5g== + dependencies: + axios "^0.19.0" + chalk "^2.4.2" + highlight.js@^9.6.0: version "9.18.3" resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.3.tgz#a1a0a2028d5e3149e2380f8a865ee8516703d634" From 5eda92c4c3a171f2c72a49e405b535606c556659 Mon Sep 17 00:00:00 2001 From: Keisuke Kan <9renpoto@gmail.com> Date: Tue, 17 Nov 2020 22:47:55 +0900 Subject: [PATCH 3/3] fix: github_token --- .github/workflows/nodejs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 2709d2ee..e7f112ad 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -42,9 +42,9 @@ jobs: POSTGRES_PASSWORD: postgres POSTGRES_DB: postgres - name: Coveralls - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v1.1.2 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.github_token }} - uses: codecov/codecov-action@v1.0.15 with: token: ${{ secrets.CODECOV_TOKEN }}