From d1c79d5e67d4c45dc492062e5c0270e3e36868a1 Mon Sep 17 00:00:00 2001 From: "Alex M. - Clockwork" Date: Thu, 14 Mar 2024 19:24:45 +0200 Subject: [PATCH] feat: Move graphql endpoitns to .env --- .env.example | 3 ++- codegen.ts | 6 ++++-- package.json | 1 + pnpm-lock.yaml | 3 +++ src/main.ts | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index c39927a..e714164 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ ENDPOINT=http://localhost:3000 STORAGE_KEY=github-comment-jwt -REPO=stuyk/giscus \ No newline at end of file +REPO=stuyk/giscus +VITE_GRAPHQL_ENDPOINT=http://164.92.143.81:8080/v1/graphql \ No newline at end of file diff --git a/codegen.ts b/codegen.ts index 8d03580..50556d8 100644 --- a/codegen.ts +++ b/codegen.ts @@ -1,7 +1,9 @@ import { CodegenConfig } from "@graphql-codegen/cli"; - +import dotenv from "dotenv"; +dotenv.config(); +console.log(process); const config: CodegenConfig = { - schema: "http://164.92.143.81:8080/v1/graphql", + schema: process.env.VITE_GRAPHQL_ENDPOINT ?? "http://164.92.143.81:8080/v1/graphql", documents: ["src/**/*.graphql"], generates: { "./src/gql/": { diff --git a/package.json b/package.json index 431e2b2..f6cd9b4 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "@vue/eslint-config-typescript": "^12.0.0", "@vue/tsconfig": "^0.5.1", "autoprefixer": "^10.4.17", + "dotenv": "^16.4.5", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9029b35..454a8e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,6 +112,9 @@ devDependencies: autoprefixer: specifier: ^10.4.17 version: 10.4.17(postcss@8.4.33) + dotenv: + specifier: ^16.4.5 + version: 16.4.5 eslint: specifier: ^8.56.0 version: 8.56.0 diff --git a/src/main.ts b/src/main.ts index 1519d4f..8739663 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,7 @@ import IconVue from "./components/ui/Icon.vue"; // HTTP connection to the API const httpLink = createHttpLink({ // You should use an absolute URL here - uri: "http://164.92.143.81:8080/v1/graphql", + uri: import.meta.env.VITE_GRAPHQL_ENDPOINT ?? "http://164.92.143.81:8080/v1/graphql", }); // Cache implementation