Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Remove octokit (#417)

1ilit66f41d591ac5
diff --git a/.env.sample b/.env.sample
index 153c5ae7..c87806fb 100644
--- a/.env.sample
+++ b/.env.sample
@@ -1,2 +1 @@
-VITE_BACKEND_URL=http://backend.com
-VITE_GITHUB_ACCESS_TOKEN=my_access_token
\ No newline at end of file
+VITE_BACKEND_URL=http://backend.com
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 9d174e14..77c73da4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -28,7 +28,6 @@
"jszip": "^3.10.1",
"lexical": "^0.12.5",
"node-sql-parser": "^5.3.8",
- "octokit": "^4.0.2",
"oracle-sql-parser": "^0.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
@@ -1497,333 +1496,6 @@
"node": ">= 8"
}
},
- "node_modules/@octokit/app": {
- "version": "15.1.0",
- "resolved": "https://registry.npmjs.org/@octokit/app/-/app-15.1.0.tgz",
- "integrity": "sha512-TkBr7QgOmE6ORxvIAhDbZsqPkF7RSqTY4pLTtUQCvr6dTXqvi2fFo46q3h1lxlk/sGMQjqyZ0kEahkD/NyzOHg==",
- "dependencies": {
- "@octokit/auth-app": "^7.0.0",
- "@octokit/auth-unauthenticated": "^6.0.0",
- "@octokit/core": "^6.1.2",
- "@octokit/oauth-app": "^7.0.0",
- "@octokit/plugin-paginate-rest": "^11.0.0",
- "@octokit/types": "^13.0.0",
- "@octokit/webhooks": "^13.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/auth-app": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-7.1.0.tgz",
- "integrity": "sha512-cazGaJPSgeZ8NkVYeM/C5l/6IQ5vZnsI8p1aMucadCkt/bndI+q+VqwrlnWbASRmenjOkf1t1RpCKrif53U8gw==",
- "dependencies": {
- "@octokit/auth-oauth-app": "^8.1.0",
- "@octokit/auth-oauth-user": "^5.1.0",
- "@octokit/request": "^9.1.1",
- "@octokit/request-error": "^6.1.1",
- "@octokit/types": "^13.4.1",
- "lru-cache": "^10.0.0",
- "universal-github-app-jwt": "^2.2.0",
- "universal-user-agent": "^7.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/auth-app/node_modules/lru-cache": {
- "version": "10.4.3",
- "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
- "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="
- },
- "node_modules/@octokit/auth-oauth-app": {
- "version": "8.1.1",
- "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-8.1.1.tgz",
- "integrity": "sha512-5UtmxXAvU2wfcHIPPDWzVSAWXVJzG3NWsxb7zCFplCWEmMCArSZV0UQu5jw5goLQXbFyOr5onzEH37UJB3zQQg==",
- "dependencies": {
- "@octokit/auth-oauth-device": "^7.0.0",
- "@octokit/auth-oauth-user": "^5.0.1",
- "@octokit/request": "^9.0.0",
- "@octokit/types": "^13.0.0",
- "universal-user-agent": "^7.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/auth-oauth-device": {
- "version": "7.1.1",
- "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-7.1.1.tgz",
- "integrity": "sha512-HWl8lYueHonuyjrKKIup/1tiy0xcmQCdq5ikvMO1YwkNNkxb6DXfrPjrMYItNLyCP/o2H87WuijuE+SlBTT8eg==",
- "dependencies": {
- "@octokit/oauth-methods": "^5.0.0",
- "@octokit/request": "^9.0.0",
- "@octokit/types": "^13.0.0",
- "universal-user-agent": "^7.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/auth-oauth-user": {
- "version": "5.1.1",
- "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-5.1.1.tgz",
- "integrity": "sha512-rRkMz0ErOppdvEfnemHJXgZ9vTPhBuC6yASeFaB7I2yLMd7QpjfrL1mnvRPlyKo+M6eeLxrKanXJ9Qte29SRsw==",
- "dependencies": {
- "@octokit/auth-oauth-device": "^7.0.1",
- "@octokit/oauth-methods": "^5.0.0",
- "@octokit/request": "^9.0.1",
- "@octokit/types": "^13.0.0",
- "universal-user-agent": "^7.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/auth-token": {
- "version": "5.1.1",
- "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-5.1.1.tgz",
- "integrity": "sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA==",
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/auth-unauthenticated": {
- "version": "6.1.0",
- "resolved": "https://registry.npmjs.org/@octokit/auth-unauthenticated/-/auth-unauthenticated-6.1.0.tgz",
- "integrity": "sha512-zPSmfrUAcspZH/lOFQnVnvjQZsIvmfApQH6GzJrkIunDooU1Su2qt2FfMTSVPRp7WLTQyC20Kd55lF+mIYaohQ==",
- "dependencies": {
- "@octokit/request-error": "^6.0.1",
- "@octokit/types": "^13.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/core": {
- "version": "6.1.2",
- "resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.1.2.tgz",
- "integrity": "sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==",
- "dependencies": {
- "@octokit/auth-token": "^5.0.0",
- "@octokit/graphql": "^8.0.0",
- "@octokit/request": "^9.0.0",
- "@octokit/request-error": "^6.0.1",
- "@octokit/types": "^13.0.0",
- "before-after-hook": "^3.0.2",
- "universal-user-agent": "^7.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/endpoint": {
- "version": "10.1.3",
- "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.3.tgz",
- "integrity": "sha512-nBRBMpKPhQUxCsQQeW+rCJ/OPSMcj3g0nfHn01zGYZXuNDvvXudF/TYY6APj5THlurerpFN4a/dQAIAaM6BYhA==",
- "license": "MIT",
- "dependencies": {
- "@octokit/types": "^13.6.2",
- "universal-user-agent": "^7.0.2"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/graphql": {
- "version": "8.1.1",
- "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-8.1.1.tgz",
- "integrity": "sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg==",
- "dependencies": {
- "@octokit/request": "^9.0.0",
- "@octokit/types": "^13.0.0",
- "universal-user-agent": "^7.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/oauth-app": {
- "version": "7.1.3",
- "resolved": "https://registry.npmjs.org/@octokit/oauth-app/-/oauth-app-7.1.3.tgz",
- "integrity": "sha512-EHXbOpBkSGVVGF1W+NLMmsnSsJRkcrnVmDKt0TQYRBb6xWfWzoi9sBD4DIqZ8jGhOWO/V8t4fqFyJ4vDQDn9bg==",
- "dependencies": {
- "@octokit/auth-oauth-app": "^8.0.0",
- "@octokit/auth-oauth-user": "^5.0.1",
- "@octokit/auth-unauthenticated": "^6.0.0-beta.1",
- "@octokit/core": "^6.0.0",
- "@octokit/oauth-authorization-url": "^7.0.0",
- "@octokit/oauth-methods": "^5.0.0",
- "@types/aws-lambda": "^8.10.83",
- "universal-user-agent": "^7.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/oauth-authorization-url": {
- "version": "7.1.1",
- "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-7.1.1.tgz",
- "integrity": "sha512-ooXV8GBSabSWyhLUowlMIVd9l1s2nsOGQdlP2SQ4LnkEsGXzeCvbSbCPdZThXhEFzleGPwbapT0Sb+YhXRyjCA==",
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/oauth-methods": {
- "version": "5.1.2",
- "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-5.1.2.tgz",
- "integrity": "sha512-C5lglRD+sBlbrhCUTxgJAFjWgJlmTx5bQ7Ch0+2uqRjYv7Cfb5xpX4WuSC9UgQna3sqRGBL9EImX9PvTpMaQ7g==",
- "dependencies": {
- "@octokit/oauth-authorization-url": "^7.0.0",
- "@octokit/request": "^9.1.0",
- "@octokit/request-error": "^6.1.0",
- "@octokit/types": "^13.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/openapi-types": {
- "version": "24.2.0",
- "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-24.2.0.tgz",
- "integrity": "sha512-9sIH3nSUttelJSXUrmGzl7QUBFul0/mB8HRYl3fOlgHbIWG+WnYDXU3v/2zMtAvuzZ/ed00Ei6on975FhBfzrg==",
- "license": "MIT"
- },
- "node_modules/@octokit/openapi-webhooks-types": {
- "version": "8.3.0",
- "resolved": "https://registry.npmjs.org/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-8.3.0.tgz",
- "integrity": "sha512-vKLsoR4xQxg4Z+6rU/F65ItTUz/EXbD+j/d4mlq2GW8TsA4Tc8Kdma2JTAAJ5hrKWUQzkR/Esn2fjsqiVRYaQg=="
- },
- "node_modules/@octokit/plugin-paginate-graphql": {
- "version": "5.2.2",
- "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-5.2.2.tgz",
- "integrity": "sha512-7znSVvlNAOJisCqAnjN1FtEziweOHSjPGAuc5W58NeGNAr/ZB57yCsjQbXDlWsVryA7hHQaEQPcBbJYFawlkyg==",
- "engines": {
- "node": ">= 18"
- },
- "peerDependencies": {
- "@octokit/core": ">=6"
- }
- },
- "node_modules/@octokit/plugin-paginate-rest": {
- "version": "11.6.0",
- "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.6.0.tgz",
- "integrity": "sha512-n5KPteiF7pWKgBIBJSk8qzoZWcUkza2O6A0za97pMGVrGfPdltxrfmfF5GucHYvHGZD8BdaZmmHGz5cX/3gdpw==",
- "license": "MIT",
- "dependencies": {
- "@octokit/types": "^13.10.0"
- },
- "engines": {
- "node": ">= 18"
- },
- "peerDependencies": {
- "@octokit/core": ">=6"
- }
- },
- "node_modules/@octokit/plugin-rest-endpoint-methods": {
- "version": "13.2.4",
- "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.2.4.tgz",
- "integrity": "sha512-gusyAVgTrPiuXOdfqOySMDztQHv6928PQ3E4dqVGEtOvRXAKRbJR4b1zQyniIT9waqaWk/UDaoJ2dyPr7Bk7Iw==",
- "dependencies": {
- "@octokit/types": "^13.5.0"
- },
- "engines": {
- "node": ">= 18"
- },
- "peerDependencies": {
- "@octokit/core": ">=6"
- }
- },
- "node_modules/@octokit/plugin-retry": {
- "version": "7.1.1",
- "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-7.1.1.tgz",
- "integrity": "sha512-G9Ue+x2odcb8E1XIPhaFBnTTIrrUDfXN05iFXiqhR+SeeeDMMILcAnysOsxUpEWcQp2e5Ft397FCXTcPkiPkLw==",
- "dependencies": {
- "@octokit/request-error": "^6.0.0",
- "@octokit/types": "^13.0.0",
- "bottleneck": "^2.15.3"
- },
- "engines": {
- "node": ">= 18"
- },
- "peerDependencies": {
- "@octokit/core": ">=6"
- }
- },
- "node_modules/@octokit/plugin-throttling": {
- "version": "9.3.1",
- "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-9.3.1.tgz",
- "integrity": "sha512-Qd91H4liUBhwLB2h6jZ99bsxoQdhgPk6TdwnClPyTBSDAdviGPceViEgUwj+pcQDmB/rfAXAXK7MTochpHM3yQ==",
- "dependencies": {
- "@octokit/types": "^13.0.0",
- "bottleneck": "^2.15.3"
- },
- "engines": {
- "node": ">= 18"
- },
- "peerDependencies": {
- "@octokit/core": "^6.0.0"
- }
- },
- "node_modules/@octokit/request": {
- "version": "9.2.2",
- "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.2.2.tgz",
- "integrity": "sha512-dZl0ZHx6gOQGcffgm1/Sf6JfEpmh34v3Af2Uci02vzUYz6qEN6zepoRtmybWXIGXFIK8K9ylE3b+duCWqhArtg==",
- "license": "MIT",
- "dependencies": {
- "@octokit/endpoint": "^10.1.3",
- "@octokit/request-error": "^6.1.7",
- "@octokit/types": "^13.6.2",
- "fast-content-type-parse": "^2.0.0",
- "universal-user-agent": "^7.0.2"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/request-error": {
- "version": "6.1.7",
- "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.7.tgz",
- "integrity": "sha512-69NIppAwaauwZv6aOzb+VVLwt+0havz9GT5YplkeJv7fG7a40qpLt/yZKyiDxAhgz0EtgNdNcb96Z0u+Zyuy2g==",
- "license": "MIT",
- "dependencies": {
- "@octokit/types": "^13.6.2"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/types": {
- "version": "13.10.0",
- "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.10.0.tgz",
- "integrity": "sha512-ifLaO34EbbPj0Xgro4G5lP5asESjwHracYJvVaPIyXMuiuXLlhic3S47cBdTb+jfODkTE5YtGCLt3Ay3+J97sA==",
- "license": "MIT",
- "dependencies": {
- "@octokit/openapi-types": "^24.2.0"
- }
- },
- "node_modules/@octokit/webhooks": {
- "version": "13.3.0",
- "resolved": "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-13.3.0.tgz",
- "integrity": "sha512-TUkJLtI163Bz5+JK0O+zDkQpn4gKwN+BovclUvCj6pI/6RXrFqQvUMRS2M+Rt8Rv0qR3wjoMoOPmpJKeOh0nBg==",
- "dependencies": {
- "@octokit/openapi-webhooks-types": "8.3.0",
- "@octokit/request-error": "^6.0.1",
- "@octokit/webhooks-methods": "^5.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
- "node_modules/@octokit/webhooks-methods": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-5.1.0.tgz",
- "integrity": "sha512-yFZa3UH11VIxYnnoOYCVoJ3q4ChuSOk2IVBBQ0O3xtKX4x9bmKb/1t+Mxixv2iUhzMdOl1qeWJqEhouXXzB3rQ==",
- "engines": {
- "node": ">= 18"
- }
- },
"node_modules/@remix-run/router": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.14.0.tgz",
@@ -2367,11 +2039,6 @@
"tailwindcss": "4.0.14"
}
},
- "node_modules/@types/aws-lambda": {
- "version": "8.10.143",
- "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.143.tgz",
- "integrity": "sha512-u5vzlcR14ge/4pMTTMDQr3MF0wEe38B2F9o84uC4F43vN5DGTy63npRrB6jQhyt+C0lGv4ZfiRcRkqJoZuPnmg=="
- },
"node_modules/@types/babel__core": {
"version": "7.20.5",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
@@ -2851,11 +2518,6 @@
"node": ">= 0.6.0"
}
},
- "node_modules/before-after-hook": {
- "version": "3.0.2",
- "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-3.0.2.tgz",
- "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A=="
- },
"node_modules/bezier-easing": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz",
@@ -2871,11 +2533,6 @@
"node": ">=0.6"
}
},
- "node_modules/bottleneck": {
- "version": "2.19.5",
- "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz",
- "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw=="
- },
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -3987,22 +3644,6 @@
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
"license": "MIT"
},
- "node_modules/fast-content-type-parse": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-2.0.1.tgz",
- "integrity": "sha512-nGqtvLrj5w0naR6tDPfB4cUmYCqouzyQiz6C5y/LtcDllJdrcc6WaWW6iXyIIOErTa/XRybj28aasdn4LkVk6Q==",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/fastify"
- },
- {
- "type": "opencollective",
- "url": "https://opencollective.com/fastify"
- }
- ],
- "license": "MIT"
- },
"node_modules/fast-copy": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.0.2.tgz",
@@ -6705,26 +6346,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/octokit": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/octokit/-/octokit-4.0.2.tgz",
- "integrity": "sha512-wbqF4uc1YbcldtiBFfkSnquHtECEIpYD78YUXI6ri1Im5OO2NLo6ZVpRdbJpdnpZ05zMrVPssNiEo6JQtea+Qg==",
- "dependencies": {
- "@octokit/app": "^15.0.0",
- "@octokit/core": "^6.0.0",
- "@octokit/oauth-app": "^7.0.0",
- "@octokit/plugin-paginate-graphql": "^5.0.0",
- "@octokit/plugin-paginate-rest": "^11.0.0",
- "@octokit/plugin-rest-endpoint-methods": "^13.0.0",
- "@octokit/plugin-retry": "^7.0.0",
- "@octokit/plugin-throttling": "^9.0.0",
- "@octokit/request-error": "^6.0.0",
- "@octokit/types": "^13.0.0"
- },
- "engines": {
- "node": ">= 18"
- }
- },
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@@ -8167,16 +7788,6 @@
"url": "https://opencollective.com/unified"
}
},
- "node_modules/universal-github-app-jwt": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-2.2.0.tgz",
- "integrity": "sha512-G5o6f95b5BggDGuUfKDApKaCgNYy2x7OdHY0zSMF081O0EJobw+1130VONhrA7ezGSV2FNOGyM+KQpQZAr9bIQ=="
- },
- "node_modules/universal-user-agent": {
- "version": "7.0.2",
- "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",
- "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q=="
- },
"node_modules/update-browserslist-db": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz",
diff --git a/package.json b/package.json
index 0c2fa2ac..d827c486 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,6 @@
"jszip": "^3.10.1",
"lexical": "^0.12.5",
"node-sql-parser": "^5.3.8",
- "octokit": "^4.0.2",
"oracle-sql-parser": "^0.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
diff --git a/src/api/gists.js b/src/api/gists.js
new file mode 100644
index 00000000..d2b7b397
--- /dev/null
+++ b/src/api/gists.js
@@ -0,0 +1,34 @@
+import axios from "axios";
+
+const filename = "share.json";
+const description = "drawDB diagram";
+
+const baseUrl = import.meta.env.VITE_BACKEND_URL;
+
+export async function create(content) {
+ const res = await axios.post(`${baseUrl}/gists`, {
+ public: false,
+ filename,
+ description,
+ content,
+ });
+
+ return res.data.id;
+}
+
+export async function patch(gistId, content) {
+ await axios.patch(`${baseUrl}/gists/${gistId}`, {
+ filename,
+ content,
+ });
+}
+
+export async function del(gistId) {
+ await axios.delete(`${baseUrl}/gists/${gistId}`);
+}
+
+export async function get(gistId) {
+ const res = await axios.get(`${baseUrl}/gists/${gistId}`);
+
+ return res.data;
+}
diff --git a/src/api/index.js b/src/api/index.js
deleted file mode 100644
index bfd43629..00000000
--- a/src/api/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { send } from "./email";
-
-export const api = {
- email: {
- send,
- },
-};
diff --git a/src/components/EditorHeader/Modal/Share.jsx b/src/components/EditorHeader/Modal/Share.jsx
index 546e3bb6..845b542d 100644
--- a/src/components/EditorHeader/Modal/Share.jsx
+++ b/src/components/EditorHeader/Modal/Share.jsx
@@ -1,4 +1,4 @@
-import { Button, Input, Spin, Toast } from "@douyinfe/semi-ui";
+import { Banner, Button, Input, Spin, Toast } from "@douyinfe/semi-ui";
import { useCallback, useContext, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { IdContext } from "../../Workspace";
@@ -12,8 +12,8 @@ import {
useTypes,
} from "../../../hooks";
import { databases } from "../../../data/databases";
-import { octokit } from "../../../data/octokit";
import { MODAL } from "../../../data/constants";
+import { create, del, patch } from "../../../api/gists";
export default function Share({ title, setModal }) {
const { t } = useTranslation();
@@ -25,6 +25,7 @@ export default function Share({ title, setModal }) {
const { types } = useTypes();
const { enums } = useEnums();
const { transform } = useTransform();
+ const [error, setError] = useState(null);
const url =
window.location.origin + window.location.pathname + "?shareId=" + gistId;
@@ -54,80 +55,34 @@ export default function Share({ title, setModal }) {
const unshare = useCallback(async () => {
try {
- await octokit.request(`DELETE /gists/${gistId}`, {
- gist_id: gistId,
- headers: {
- "X-GitHub-Api-Version": "2022-11-28",
- },
- });
+ await del(gistId);
setGistId("");
setModal(MODAL.NONE);
} catch (e) {
console.error(e);
+ setError(e);
}
}, [gistId, setGistId, setModal]);
- const updateGist = useCallback(async () => {
- setLoading(true);
- try {
- await octokit.request(`PATCH /gists/${gistId}`, {
- gist_id: gistId,
- description: "drawDB diagram",
- files: {
- "share.json": {
- content: diagramToString(),
- },
- },
- headers: {
- "X-GitHub-Api-Version": "2022-11-28",
- },
- });
- } catch (e) {
- console.error(e);
- } finally {
- setLoading(false);
- }
- }, [gistId, diagramToString]);
-
- const generateLink = useCallback(async () => {
- setLoading(true);
- try {
- const res = await octokit.request("POST /gists", {
- description: "drawDB diagram",
- public: false,
- files: {
- "share.json": {
- content: diagramToString(),
- },
- },
- headers: {
- "X-GitHub-Api-Version": "2022-11-28",
- },
- });
- setGistId(res.data.id);
- } catch (e) {
- console.error(e);
- } finally {
- setLoading(false);
- }
- }, [setGistId, diagramToString]);
-
useEffect(() => {
const updateOrGenerateLink = async () => {
try {
+ setLoading(true);
if (!gistId || gistId === "") {
- await generateLink();
+ const res = await create(diagramToString());
+ setGistId(res.data.id);
} else {
- await updateGist();
+ await patch(gistId, diagramToString());
}
} catch (e) {
console.error(e);
+ setError(e);
} finally {
setLoading(false);
}
};
updateOrGenerateLink();
- }, [gistId, generateLink, updateGist]);
+ }, [gistId, diagramToString, setGistId]);
const copyLink = () => {
navigator.clipboard
@@ -150,18 +105,30 @@ export default function Share({ title, setModal }) {
return (
<div>
- <div className="flex gap-3">
- <Input value={url} size="large" />
- </div>
- <div className="text-xs mt-2">{t("share_info")}</div>
- <div className="flex gap-2 mt-3">
- <Button block onClick={unshare}>
- {t("unshare")}
- </Button>
- <Button block theme="solid" icon={<IconLink />} onClick={copyLink}>
- {t("copy_link")}
- </Button>
- </div>
+ {error && (
+ <Banner
+ description={t("oops_smth_went_wrong")}
+ type="danger"
+ closeIcon={null}
+ fullMode={false}
+ />
+ )}
+ {!error && (
+ <>
+ <div className="flex gap-3">
+ <Input value={url} size="large" />
+ </div>
+ <div className="text-xs mt-2">{t("share_info")}</div>
+ <div className="flex gap-2 mt-3">
+ <Button block onClick={unshare}>
+ {t("unshare")}
+ </Button>
+ <Button block theme="solid" icon={<IconLink />} onClick={copyLink}>
+ {t("copy_link")}
+ </Button>
+ </div>
+ </>
+ )}
</div>
);
}
diff --git a/src/components/Workspace.jsx b/src/components/Workspace.jsx
index faab9214..3b0fd0b0 100644
--- a/src/components/Workspace.jsx
+++ b/src/components/Workspace.jsx
@@ -24,7 +24,7 @@ import { useTranslation } from "react-i18next";
import { databases } from "../data/databases";
import { isRtl } from "../i18n/utils/rtl";
import { useSearchParams } from "react-router-dom";
-import { octokit } from "../data/octokit";
+import { get } from "../api/gists";
export const IdContext = createContext({ gistId: "" });
@@ -285,12 +285,7 @@ export default function WorkSpace() {
const loadFromGist = async (shareId) => {
try {
- const res = await octokit.request(`GET /gists/${shareId}`, {
- gist_id: shareId,
- headers: {
- "X-GitHub-Api-Version": "2022-11-28",
- },
- });
+ const res = await get(shareId);
const diagramSrc = res.data.files["share.json"].content;
const d = JSON.parse(diagramSrc);
setUndoStack([]);
diff --git a/src/data/octokit.js b/src/data/octokit.js
deleted file mode 100644
index d922073a..00000000
--- a/src/data/octokit.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { Octokit } from "octokit";
-
-export const octokit = new Octokit({
- auth: import.meta.env.VITE_GITHUB_ACCESS_TOKEN,
-});
diff --git a/src/pages/BugReport.jsx b/src/pages/BugReport.jsx
index 7de6f7c8..9d76dc58 100644
--- a/src/pages/BugReport.jsx
+++ b/src/pages/BugReport.jsx
@@ -11,7 +11,7 @@ import { $generateHtmlFromNodes } from "@lexical/html";
import { CLEAR_EDITOR_COMMAND } from "lexical";
import { Link } from "react-router-dom";
import { socials } from "../data/socials";
-import { api } from "../api";
+import { send } from "../api/email";
function Form({ theme }) {
const [editor] = useLexicalComposerContext();
@@ -61,7 +61,7 @@ function Form({ theme }) {
editor.update(() => {
const sendMail = async () => {
try {
- await api.email.send(
+ await send(
`[BUG REPORT]: ${data.title}`,
$generateHtmlFromNodes(editor),
data.attachments,