From 25d9ba446998ba47f83f1a5109c4a5cb7337d118 Mon Sep 17 00:00:00 2001 From: Samuel Andert Date: Wed, 23 Aug 2023 16:49:09 +0200 Subject: [PATCH] prod deploy next try --- .meshrc.yml | 6 +++--- {src => public}/schemas/cloudron.json | 0 {src => public}/schemas/directus.graphql | 0 {src => public}/schemas/gitea.yml | 0 {src => public}/schemas/gridproxy.json | 0 src/fetch-schema.js | 2 +- src/resolvers/subs_directus.js | 8 ++++++-- 7 files changed, 10 insertions(+), 6 deletions(-) rename {src => public}/schemas/cloudron.json (100%) rename {src => public}/schemas/directus.graphql (100%) rename {src => public}/schemas/gitea.yml (100%) rename {src => public}/schemas/gridproxy.json (100%) diff --git a/.meshrc.yml b/.meshrc.yml index dcff1f2..0c5d7b6 100644 --- a/.meshrc.yml +++ b/.meshrc.yml @@ -6,7 +6,7 @@ sources: handler: graphql: endpoint: https://directus.andert.me/graphql - source: ./src/schemas/directus.graphql + source: ./public/schemas/directus.graphql operationHeaders: Authorization: Bearer {env.DIRECTUS_API} additionalResolvers: @@ -16,13 +16,13 @@ additionalResolvers: # handler: # openapi: # endpoint: https://my.andert.me/api/v1 - # source: ./src/schemas/cloudron.json + # source: ./public/schemas/cloudron.json # operationHeaders: # Authorization: Bearer {env.CLOUDRON_API} # - name: Gitea # handler: # openapi: # endpoint: https://git.andert.me/api/v1 - # source: ./src/schemas/gitea.yml + # source: ./public/schemas/gitea.yml # operationHeaders: # Authorization: Bearer {env.GITEA_API} diff --git a/src/schemas/cloudron.json b/public/schemas/cloudron.json similarity index 100% rename from src/schemas/cloudron.json rename to public/schemas/cloudron.json diff --git a/src/schemas/directus.graphql b/public/schemas/directus.graphql similarity index 100% rename from src/schemas/directus.graphql rename to public/schemas/directus.graphql diff --git a/src/schemas/gitea.yml b/public/schemas/gitea.yml similarity index 100% rename from src/schemas/gitea.yml rename to public/schemas/gitea.yml diff --git a/src/schemas/gridproxy.json b/public/schemas/gridproxy.json similarity index 100% rename from src/schemas/gridproxy.json rename to public/schemas/gridproxy.json diff --git a/src/fetch-schema.js b/src/fetch-schema.js index 68bf292..0fb368b 100644 --- a/src/fetch-schema.js +++ b/src/fetch-schema.js @@ -24,7 +24,7 @@ async function fetchSchema() { }); // Save the schema to a file - fs.writeFileSync('./src/schemas/directus.graphql', schema); + fs.writeFileSync('./public/schemas/directus.graphql', schema); } fetchSchema().catch(console.error); diff --git a/src/resolvers/subs_directus.js b/src/resolvers/subs_directus.js index 8192ea7..5d96398 100644 --- a/src/resolvers/subs_directus.js +++ b/src/resolvers/subs_directus.js @@ -7,8 +7,12 @@ const path = require('path') const pubsub = new PubSub(); -// Generate an absolute path to the schema file -const schemaFilePath = path.resolve(process.cwd(), 'src/schemas/directus.graphql'); +let schemaFilePath; +if (process.env.NODE_ENV === 'production') { + schemaFilePath = path.resolve(process.cwd(), 'schemas/directus.graphql'); +} else { + schemaFilePath = path.resolve(process.cwd(), 'public/schemas/directus.graphql'); +} // Read the schema file const schema = fs.readFileSync(schemaFilePath, 'utf8');