diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bc62f8f75..e0d96c1d3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,10 +23,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Use Node.js 18 + - name: Use Node.js 21 uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 21 - name: Install dependencies run: yarn diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 337c8fccc..bc479b794 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Use Node.js 18 + - name: Use Node.js 21 uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 21 - name: Install dependencies run: yarn diff --git a/.gitignore b/.gitignore index b068fa08d..d75671c4c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ release/ .env idée.txt +appwrite/appwrite.tar.gz diff --git a/appwrite/main.js b/appwrite/main.js index 035980af5..f514ddc8a 100644 --- a/appwrite/main.js +++ b/appwrite/main.js @@ -1,11 +1,27 @@ const fetch2 = require('node-fetch'); const axios = require('axios'); -module.exports = async (req, res) => { +module.exports = async ({ req, res }) => { console.log("Starting function"); + // console.log("req: ", req); + // console.log("res", res); + + var payloadString = ""; + if (req.payload) { + payloadString = req.payload; + } else if (req.body) { + payloadString = req.body; + } else if (req.query) { + payloadString = req.query; + } else { + return res.json({ message: "No payload found!" }, 400) + } + + // console.log('payloadString: ', payloadString) + try { - const payload = JSON.parse(req.payload) + const payload = JSON.parse(payloadString) const type = payload["type"]; @@ -13,12 +29,14 @@ module.exports = async (req, res) => { const query = payload["query"]; console.log('query: ', query) + // console.log(process.env.GOOGLE_API_KEY) + const google_api_key = - req.variables.GOOGLE_API_KEY || + process.env.GOOGLE_API_KEY || console.log('GOOGLE_API_KEY variable not found. You can set it in Function settings.'); const google_cse_id = - req.variables.GOOGLE_CSE_ID || + process.env.GOOGLE_CSE_ID || console.log('GOOGLE_CSE_ID variable not found. You can set it in Function settings.'); var fetch_res = await fetch2( @@ -27,14 +45,14 @@ module.exports = async (req, res) => { )}` ); - // console.log(fetch_res.status) + // console.log('fetch_res: ', fetch_res) if (fetch_res.status != 200) { - res.json({ message: "status not 200! " + (await fetch_res.text()) }, fetch_res.status) + return res.json({ message: "status not 200! " + (await fetch_res.text()) }, fetch_res.status) } else { var j = await fetch_res.json(); // console.log(j) - res.json(j, fetch_res.status) + return res.json(j, fetch_res.status) } } else if (type == "cors") { const url = payload["url"]; @@ -43,35 +61,36 @@ module.exports = async (req, res) => { const config = { headers: options.headers } if (options.method == "GET") { axios_res = axios.get(url, config).catch(error => { - res.json({ message: "Error: " + error }, 400) + return res.json({ message: "Error: " + error }, 400) }); } else if (options.method == "POST") { axios_res = axios.post(url, options.body, config).catch(error => { - res.json({ message: "Error: " + error }, 400) + return res.json({ message: "Error: " + error }, 400) }); } else if (options.method == "PUT") { axios_res = axios.put(url, options.body, config).catch(error => { - res.json({ message: "Error: " + error }, 400) + return res.json({ message: "Error: " + error }, 400) }); } else if (options.method == "PATCH") { axios_res = axios.patch(url, options.body, config).catch(error => { - res.json({ message: "Error: " + error }, 400) + return res.json({ message: "Error: " + error }, 400) }); } else if (options.method == "DELETE") { axios_res = axios.delete(url, options.body).catch(error => { - res.json({ message: "Error: " + error }, 400) + return res.json({ message: "Error: " + error }, 400) }); } axios_res.then(resp => { - res.json({ message: resp.data }, resp.status); + return res.json({ message: resp.data }, resp.status); }).catch(error => { - res.json({ message: "Error: " + error }, 400) + return res.json({ message: "Error: " + error }, 400) }) } else { - res.json({ message: "Invalid type!" }, 400) + return res.json({ message: "Invalid type!" }, 400) } } catch (error) { - res.json({ message: "An error occured!" }, 400) + console.log('error: ', error) + return res.json({ message: "An error occured!" }, 400) } }; diff --git a/dev-dist/sw.js b/dev-dist/sw.js index aab3454a2..5ba3a768e 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -67,7 +67,7 @@ if (!self.define) { }); }; } -define(['./workbox-340e2aff'], (function (workbox) { 'use strict'; +define(['./workbox-148cb7e5'], (function (workbox) { 'use strict'; self.skipWaiting(); workbox.clientsClaim(); diff --git a/tsconfig.json b/tsconfig.json index 9998db11e..1fdb08283 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,11 @@ "compilerOptions": { "target": "ESNext", "useDefineForClassFields": true, - "lib": ["DOM", "DOM.Iterable", "ESNext"], + "lib": [ + "DOM", + "DOM.Iterable", + "ESNext" + ], "allowJs": false, "skipLibCheck": true, "esModuleInterop": false, @@ -17,18 +21,49 @@ "jsx": "react-jsx", "baseUrl": ".", "paths": { - "@icon/*": ["./src/assets/icons/*"], - "@type/*": ["./src/types/*"], - "@store/*": ["./src/store/*"], - "@hooks/*": ["./src/hooks/*"], - "@constants/*": ["./src/constants/*"], - "@api/*": ["./src/api/*"], - "@components/*": ["./src/components/*"], - "@utils/*": ["./src/utils/*"], - "@src/*": ["./src/*"], - "@openai_function_calling_tools/*": ["./src/openai_function_calling_tools/*"] - } + "@icon/*": [ + "./src/assets/icons/*" + ], + "@type/*": [ + "./src/types/*" + ], + "@store/*": [ + "./src/store/*" + ], + "@hooks/*": [ + "./src/hooks/*" + ], + "@constants/*": [ + "./src/constants/*" + ], + "@api/*": [ + "./src/api/*" + ], + "@components/*": [ + "./src/components/*" + ], + "@utils/*": [ + "./src/utils/*" + ], + "@src/*": [ + "./src/*" + ], + "@openai_function_calling_tools/*": [ + "./src/openai_function_calling_tools/*" + ] + }, + "typeRoots": [ + "./node_modules/@types", + "./src/types" + ], }, - "include": ["src", "electron/index.cjs"], - "references": [{ "path": "./tsconfig.node.json" }] -} + "include": [ + "src", + "electron/index.cjs" + ], + "references": [ + { + "path": "./tsconfig.node.json" + } + ] +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index e2b713698..a36bb589b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1042,9 +1042,6 @@ resolved "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.0.tgz" integrity sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg== -"@esbuild/linux-x64@0.17.15": - version "0.17.15" - "@fortawesome/fontawesome-common-types@6.4.0": version "6.4.0" resolved "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.4.0.tgz" @@ -1270,12 +1267,6 @@ magic-string "^0.25.0" string.prototype.matchall "^4.0.6" -"@swc/core-linux-x64-gnu@1.3.44": - version "1.3.44" - -"@swc/core-linux-x64-musl@1.3.44": - version "1.3.44" - "@swc/core@^1.3.10", "@swc/core@^1.3.35": version "1.3.44" optionalDependencies: