From 55d634d40b9530e441527a0f1b96f8ac5a2c3f61 Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Mon, 6 May 2024 17:27:45 +0530 Subject: [PATCH 1/8] feat: initial poc --- apps/console/package.json | 1 + apps/console/src/app/api/og/route.tsx | 47 +++++++++++++++++++++++++++ apps/console/src/app/robots.ts | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 apps/console/src/app/api/og/route.tsx diff --git a/apps/console/package.json b/apps/console/package.json index 51d1c11efa..4f6543f339 100644 --- a/apps/console/package.json +++ b/apps/console/package.json @@ -43,6 +43,7 @@ "@radix-ui/react-toast": "^1.1.4", "@tailwindcss/typography": "^0.5.10", "@tanstack/react-table": "^8.9.3", + "@vercel/og": "^0.6.2", "axios": "^1.6.8", "clsx": "^1.1.1", "cookie": "^0.5.0", diff --git a/apps/console/src/app/api/og/route.tsx b/apps/console/src/app/api/og/route.tsx new file mode 100644 index 0000000000..8ae07e550c --- /dev/null +++ b/apps/console/src/app/api/og/route.tsx @@ -0,0 +1,47 @@ +import { ImageResponse } from 'next/og'; +// App router includes @vercel/og. +// No need to install it. + +export async function GET(request: Request) { + const { searchParams } = new URL(request.url); + const username = searchParams.get('username'); + if (!username) { + return new ImageResponse(<>Visit with "?username=vercel", { + width: 1200, + height: 630, + }); + } + + return new ImageResponse( + ( +
+ +

github.com/{username}

+
+ ), + { + width: 1200, + height: 630, + }, + ); +} \ No newline at end of file diff --git a/apps/console/src/app/robots.ts b/apps/console/src/app/robots.ts index f7f9959050..241a1b2c5c 100644 --- a/apps/console/src/app/robots.ts +++ b/apps/console/src/app/robots.ts @@ -4,7 +4,7 @@ export default function robots(): MetadataRoute.Robots { return { rules: { userAgent: "*", - allow: "/", + allow: ["/", "/api/og/*"], disallow: "/private/", }, sitemap: "https://instill.tech/sitemap.xml", From e5e5dac4086027a22495f7ba326c300111964def Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Thu, 16 May 2024 21:47:30 +0530 Subject: [PATCH 2/8] feat: pipeline and user og:image --- apps/console/public/images/blur.svg | 68 +++++++ apps/console/src/app/[entity]/page.tsx | 2 +- .../src/app/[entity]/pipelines/[id]/page.tsx | 4 +- apps/console/src/app/api/og/route.tsx | 47 ----- apps/console/src/app/api/pipeline/route.tsx | 166 +++++++++++++++++ apps/console/src/app/api/user/route.tsx | 173 ++++++++++++++++++ pnpm-lock.yaml | 117 +++++++++++- 7 files changed, 525 insertions(+), 52 deletions(-) create mode 100644 apps/console/public/images/blur.svg delete mode 100644 apps/console/src/app/api/og/route.tsx create mode 100644 apps/console/src/app/api/pipeline/route.tsx create mode 100644 apps/console/src/app/api/user/route.tsx diff --git a/apps/console/public/images/blur.svg b/apps/console/public/images/blur.svg new file mode 100644 index 0000000000..d877241ea2 --- /dev/null +++ b/apps/console/public/images/blur.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/console/src/app/[entity]/page.tsx b/apps/console/src/app/[entity]/page.tsx index 05f32501dd..7fb41d3e1f 100644 --- a/apps/console/src/app/[entity]/page.tsx +++ b/apps/console/src/app/[entity]/page.tsx @@ -24,7 +24,7 @@ export async function generateMetadata({ title: `Instill Core | ${params.entity}`, description: user.profile?.bio, openGraph: { - images: ["/instill-open-graph.png"], + images: [`/api/user?user=${params.entity}`], }, }; diff --git a/apps/console/src/app/[entity]/pipelines/[id]/page.tsx b/apps/console/src/app/[entity]/pipelines/[id]/page.tsx index 11bdde294e..8e70e9f947 100644 --- a/apps/console/src/app/[entity]/pipelines/[id]/page.tsx +++ b/apps/console/src/app/[entity]/pipelines/[id]/page.tsx @@ -52,10 +52,12 @@ export async function generateMetadata({ title: `Instill Core | ${id}`, description: pipeline?.readme, openGraph: { - images: ["/instill-open-graph.png"], + images: [`/api/pipeline?user=${entity}&pipeline=${id}`], }, }; + console.log(metadata, Promise.resolve(metadata)); + return Promise.resolve(metadata); } catch (error) { console.log(error); diff --git a/apps/console/src/app/api/og/route.tsx b/apps/console/src/app/api/og/route.tsx deleted file mode 100644 index 8ae07e550c..0000000000 --- a/apps/console/src/app/api/og/route.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { ImageResponse } from 'next/og'; -// App router includes @vercel/og. -// No need to install it. - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url); - const username = searchParams.get('username'); - if (!username) { - return new ImageResponse(<>Visit with "?username=vercel", { - width: 1200, - height: 630, - }); - } - - return new ImageResponse( - ( -
- -

github.com/{username}

-
- ), - { - width: 1200, - height: 630, - }, - ); -} \ No newline at end of file diff --git a/apps/console/src/app/api/pipeline/route.tsx b/apps/console/src/app/api/pipeline/route.tsx new file mode 100644 index 0000000000..4ddb58c0d8 --- /dev/null +++ b/apps/console/src/app/api/pipeline/route.tsx @@ -0,0 +1,166 @@ +import { fetchUserPipeline } from "@instill-ai/toolkit/server"; +import { ImageResponse } from "next/og"; +// App router includes @vercel/og. +// No need to install it. + +export async function GET(request: Request) { + const { searchParams } = new URL(request.url); + const pipelineName = searchParams.get("pipeline"); + const userName = searchParams.get("user") || searchParams.get("amp;user"); + + const pipeline = await fetchUserPipeline({ + pipelineName: `users/${userName}/pipelines/${pipelineName}`, + accessToken: null, + }); + + return new ImageResponse( + ( +
+
+
+ + {pipeline.owner?.user?.id}/ + + {pipeline?.id} + + +
+
+ +
+
+
+ + {pipeline.description.slice(0, 200)} + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + {/* */} +
+
+ ), + { + width: 1110, + height: 560, + } + ); +} diff --git a/apps/console/src/app/api/user/route.tsx b/apps/console/src/app/api/user/route.tsx new file mode 100644 index 0000000000..b71086bdb1 --- /dev/null +++ b/apps/console/src/app/api/user/route.tsx @@ -0,0 +1,173 @@ +// "use client"; + +import { fetchUser } from "@instill-ai/toolkit/server"; +import { ImageResponse } from "next/og"; +// App router includes @vercel/og. +// No need to install it. + +export async function GET(request: Request) { + const { searchParams } = new URL(request.url); + + const userName = searchParams.get("user"); + + const user = await fetchUser({ + userName: "users/" + userName, + // This is a public route, we don't need to request it with access token + accessToken: null, + }); + + console.log({ user }); + + return new ImageResponse( + ( +
+
+
+ + {user.profile?.display_name} - + + {" "} + {user?.id} + + +
+
+ +
+
+
+ + {user.profile?.bio?.slice(0, 200)} + +
+
+ {/* */} + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/* */} +
+
+ ), + { + width: 1110, + height: 560, + } + ); +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d72ecc8437..45f3dcdf9f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -101,6 +101,9 @@ importers: '@tanstack/react-table': specifier: ^8.9.3 version: 8.11.7(react-dom@18.2.0)(react@18.2.0) + '@vercel/og': + specifier: ^0.6.2 + version: 0.6.2 axios: specifier: ^1.6.8 version: 1.6.8 @@ -6378,6 +6381,11 @@ packages: type-fest: 2.19.0 dev: false + /@resvg/resvg-wasm@2.4.0: + resolution: {integrity: sha512-C7c51Nn4yTxXFKvgh2txJFNweaVcfUPQxwEUFw4aWsCmfiBDJsTSwviIF8EcwjQ6k8bPyMWCl1vw4BdxE569Cg==} + engines: {node: '>= 10'} + dev: false + /@rollup/plugin-babel@5.3.1(@babel/core@7.23.7)(rollup@2.79.1): resolution: {integrity: sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q==} engines: {node: '>= 10.0.0'} @@ -6545,6 +6553,15 @@ packages: /@rushstack/eslint-patch@1.7.0: resolution: {integrity: sha512-Jh4t/593gxs0lJZ/z3NnasKlplXT2f+4y/LZYuaKZW5KAaiVFL/fThhs+17EbUd53jUVJ0QudYCBGbN/psvaqg==} + /@shuding/opentype.js@1.4.0-beta.0: + resolution: {integrity: sha512-3NgmNyH3l/Hv6EvsWJbsvpcpUba6R8IREQ83nH83cyakCw7uM1arZKNfHwv1Wz6jgqrF/j4x5ELvR6PnK9nTcA==} + engines: {node: '>= 8.0.0'} + hasBin: true + dependencies: + fflate: 0.7.4 + string.prototype.codepointat: 0.2.1 + dev: false + /@sinclair/typebox@0.27.8: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} dev: true @@ -8684,6 +8701,15 @@ packages: /@ungap/structured-clone@1.2.0: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} + /@vercel/og@0.6.2: + resolution: {integrity: sha512-OTe0KE37F5Y2eTys6eMnfopC+P4qr2ooXUTFyFPTplYSPwowmFk/HLD1FXtbKLjqsIH0SgekcJWad+C5uX4nkg==} + engines: {node: '>=16'} + dependencies: + '@resvg/resvg-wasm': 2.4.0 + satori: 0.10.9 + yoga-wasm-web: 0.3.3 + dev: false + /@vitejs/plugin-react@4.2.1(vite@5.0.12): resolution: {integrity: sha512-oojO9IDc4nCUUi8qIR11KoQm0XFFLIwsRBwHRR4d/88IWghn1y6ckz/bJ8GHDCsYEJee8mDzqtJxh15/cisJNQ==} engines: {node: ^14.18.0 || >=16.0.0} @@ -9446,6 +9472,11 @@ packages: /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + /base64-js@0.0.8: + resolution: {integrity: sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw==} + engines: {node: '>= 0.4'} + dev: false + /base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -9709,6 +9740,10 @@ packages: engines: {node: '>=6'} dev: true + /camelize@1.0.1: + resolution: {integrity: sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==} + dev: false + /caniuse-lite@1.0.30001579: resolution: {integrity: sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==} @@ -10375,6 +10410,19 @@ packages: engines: {node: '>=8'} dev: true + /css-background-parser@0.1.0: + resolution: {integrity: sha512-2EZLisiZQ+7m4wwur/qiYJRniHX4K5Tc9w93MT3AS0WS1u5kaZ4FKXlOTBhOjc+CgEgPiGY+fX1yWD8UwpEqUA==} + dev: false + + /css-box-shadow@1.0.0-3: + resolution: {integrity: sha512-9jaqR6e7Ohds+aWwmhe6wILJ99xYQbfmK9QQB9CcMjDbTxPZjwEmUQpU91OG05Xgm8BahT5fW+svbsQGjS/zPg==} + dev: false + + /css-color-keywords@1.0.0: + resolution: {integrity: sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==} + engines: {node: '>=4'} + dev: false + /css-loader@6.9.1(webpack@5.89.0): resolution: {integrity: sha512-OzABOh0+26JKFdMzlK6PY1u5Zx8+Ck7CVRlcGNZoY9qwJjdfu2VWFuprTIpPW+Av5TZTVViYWcFQaEEQURLknQ==} engines: {node: '>= 12.13.0'} @@ -10402,6 +10450,14 @@ packages: nth-check: 2.1.1 dev: true + /css-to-react-native@3.2.0: + resolution: {integrity: sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==} + dependencies: + camelize: 1.0.1 + css-color-keywords: 1.0.0 + postcss-value-parser: 4.2.0 + dev: false + /css-what@6.1.0: resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==} engines: {node: '>= 6'} @@ -10945,7 +11001,6 @@ packages: /emoji-regex@10.3.0: resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==} - dev: true /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -11406,7 +11461,6 @@ packages: /escape-html@1.0.3: resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==} - dev: true /escape-string-regexp@1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} @@ -12036,6 +12090,10 @@ packages: resolution: {integrity: sha512-3yurQZ2hD9VISAhJJP9bpYFNQrHHBXE2JxxjY5aLEcDi46RmAzJE2OC9FAde0yis5ElW0jTTzs0zfg/Cca4XqQ==} dev: true + /fflate@0.7.4: + resolution: {integrity: sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==} + dev: false + /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -12655,6 +12713,11 @@ packages: tslib: 2.6.2 dev: false + /hex-rgb@4.3.0: + resolution: {integrity: sha512-Ox1pJVrDCyGHMG9CFg1tmrRUMRPRsAWYc/PinY0XzJU4K7y7vjNoLKIQ7BR5UJMCxNN8EM1MNDmHWA/B3aZUuw==} + engines: {node: '>=6'} + dev: false + /highlight.js@10.7.3: resolution: {integrity: sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==} dev: false @@ -13566,6 +13629,13 @@ packages: resolution: {integrity: sha512-K2U4W2Ff5ibV7j7ydLr+zLAkIg5JJ4lPn1Ltsdt+Tz/IjQ8buJ55pZAxoP34lqIiwtF9iAvtLv3JGv7CAyAg+g==} engines: {node: '>=14'} + /linebreak@1.1.0: + resolution: {integrity: sha512-MHp03UImeVhB7XZtjd0E4n6+3xr5Dq/9xI/5FptGk5FrbDR3zagPa2DS6U8ks/3HjbKWG9Q1M2ufOzxV2qLYSQ==} + dependencies: + base64-js: 0.0.8 + unicode-trie: 2.0.0 + dev: false + /lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} @@ -15074,7 +15144,6 @@ packages: /pako@0.2.9: resolution: {integrity: sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==} - dev: true /pako@1.0.11: resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} @@ -15104,6 +15173,13 @@ packages: safe-buffer: 5.2.1 dev: true + /parse-css-color@0.2.1: + resolution: {integrity: sha512-bwS/GGIFV3b6KS4uwpzCFj4w297Yl3uqnSgIPsoQkx7GMLROXfMnWvxfNkL0oh8HVhZA4hvJoEoEIqonfJ3BWg==} + dependencies: + color-name: 1.1.4 + hex-rgb: 4.3.0 + dev: false + /parse-entities@2.0.0: resolution: {integrity: sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==} dependencies: @@ -16721,6 +16797,22 @@ packages: webpack: 5.89.0(esbuild@0.17.19) dev: true + /satori@0.10.9: + resolution: {integrity: sha512-XU9EELUEZuioT4acLIpCXxHcFzrsC8muvg0MY28d+TlqwxbkTzBmWbw+3+hnCzXT7YZ0Qm8k3eXktDaEu+qmEw==} + engines: {node: '>=16'} + dependencies: + '@shuding/opentype.js': 1.4.0-beta.0 + css-background-parser: 0.1.0 + css-box-shadow: 1.0.0-3 + css-to-react-native: 3.2.0 + emoji-regex: 10.3.0 + escape-html: 1.0.3 + linebreak: 1.1.0 + parse-css-color: 0.2.1 + postcss-value-parser: 4.2.0 + yoga-wasm-web: 0.3.3 + dev: false + /saxes@6.0.0: resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==} engines: {node: '>=v12.22.7'} @@ -17239,6 +17331,10 @@ packages: strip-ansi: 7.1.0 dev: true + /string.prototype.codepointat@0.2.1: + resolution: {integrity: sha512-2cBVCj6I4IOvEnjgO/hWqXjqBGsY+zwPmHl12Srk9IXSZ56Jwwmy+66XO5Iut/oQVR7t5ihYdLB0GMa4alEUcg==} + dev: false + /string.prototype.matchall@4.0.10: resolution: {integrity: sha512-rGXbGmOEosIQi6Qva94HUjgPs9vKW+dkG7Y8Q5O2OYkWL6wFaTRZO8zM4mhP94uX55wgyrXzfS2aGtGzUL7EJQ==} dependencies: @@ -17698,6 +17794,10 @@ packages: setimmediate: 1.0.5 dev: true + /tiny-inflate@1.0.3: + resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==} + dev: false + /tiny-invariant@1.3.1: resolution: {integrity: sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==} dev: true @@ -18201,6 +18301,13 @@ packages: engines: {node: '>=4'} dev: true + /unicode-trie@2.0.0: + resolution: {integrity: sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==} + dependencies: + pako: 0.2.9 + tiny-inflate: 1.0.3 + dev: false + /unified@10.1.2: resolution: {integrity: sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==} dependencies: @@ -19139,6 +19246,10 @@ packages: engines: {node: '>=12.20'} dev: true + /yoga-wasm-web@0.3.3: + resolution: {integrity: sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==} + dev: false + /yup@0.32.11: resolution: {integrity: sha512-Z2Fe1bn+eLstG8DRR6FTavGD+MeAwyfmouhHsIUgaADz8jvFKbO/fXc2trJKZg+5EBjh4gGm3iU/t3onKlXHIg==} engines: {node: '>=10'} From 4b61f5a5a5929679a2471e62970c13f8dfa2031f Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Fri, 17 May 2024 01:26:40 +0530 Subject: [PATCH 3/8] fix: build fix --- apps/console/src/app/api/pipeline/route.tsx | 6 ++++-- apps/console/src/app/api/user/route.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/console/src/app/api/pipeline/route.tsx b/apps/console/src/app/api/pipeline/route.tsx index 4ddb58c0d8..1c9f37dabb 100644 --- a/apps/console/src/app/api/pipeline/route.tsx +++ b/apps/console/src/app/api/pipeline/route.tsx @@ -13,6 +13,8 @@ export async function GET(request: Request) { accessToken: null, }); + const user = "user" in pipeline.owner ? pipeline.owner.user : null; + return new ImageResponse( (
- {pipeline.owner?.user?.id}/ + {user?.id}/
diff --git a/apps/console/src/app/api/user/route.tsx b/apps/console/src/app/api/user/route.tsx index b71086bdb1..cc4f988c38 100644 --- a/apps/console/src/app/api/user/route.tsx +++ b/apps/console/src/app/api/user/route.tsx @@ -42,8 +42,8 @@ export async function GET(request: Request) { style={{ fontWeight: "700", }} + tw="ml-2" > - {" "} {user?.id} From fd624e753e595882f623c293e74cc9fdd439e533 Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Mon, 20 May 2024 15:56:35 +0530 Subject: [PATCH 4/8] fix: fix --- apps/console/src/app/api/model/route.tsx | 166 ++++++++++++++++++++ apps/console/src/app/api/pipeline/route.tsx | 5 +- 2 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 apps/console/src/app/api/model/route.tsx diff --git a/apps/console/src/app/api/model/route.tsx b/apps/console/src/app/api/model/route.tsx new file mode 100644 index 0000000000..ffb2cfc71c --- /dev/null +++ b/apps/console/src/app/api/model/route.tsx @@ -0,0 +1,166 @@ +import { fetchUserModel } from "@instill-ai/toolkit/server"; +import { ImageResponse } from "next/og"; +// App router includes @vercel/og. +// No need to install it. + +export async function GET(request: Request) { + const { searchParams } = new URL(request.url); + const modelName = searchParams.get("model"); + const userName = searchParams.get("user") || searchParams.get("amp;user"); + + const model = await fetchUserModel({ + modelName: `users/${userName}/models/${modelName}`, + accessToken: null, + }); + + return new ImageResponse( + ( +
+
+
+ + {model.owner?.user?.id}/ + + {model?.id} + + +
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + {/* */} +
+
+ ), + { + width: 1110, + height: 560, + } + ); +} diff --git a/apps/console/src/app/api/pipeline/route.tsx b/apps/console/src/app/api/pipeline/route.tsx index 1c9f37dabb..8a0f6c750d 100644 --- a/apps/console/src/app/api/pipeline/route.tsx +++ b/apps/console/src/app/api/pipeline/route.tsx @@ -5,8 +5,9 @@ import { ImageResponse } from "next/og"; export async function GET(request: Request) { const { searchParams } = new URL(request.url); - const pipelineName = searchParams.get("pipeline"); - const userName = searchParams.get("user") || searchParams.get("amp;user"); + const pipelineName = + searchParams.get("pipeline") || searchParams.get("amp;pipeline"); + const userName = searchParams.get("user"); const pipeline = await fetchUserPipeline({ pipelineName: `users/${userName}/pipelines/${pipelineName}`, From 02f75d71cedf8552bb83a37daad466fc66aeba30 Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Mon, 20 May 2024 17:30:31 +0530 Subject: [PATCH 5/8] fix: build fix --- apps/console/src/app/api/model/route.tsx | 166 ----------------------- 1 file changed, 166 deletions(-) delete mode 100644 apps/console/src/app/api/model/route.tsx diff --git a/apps/console/src/app/api/model/route.tsx b/apps/console/src/app/api/model/route.tsx deleted file mode 100644 index ffb2cfc71c..0000000000 --- a/apps/console/src/app/api/model/route.tsx +++ /dev/null @@ -1,166 +0,0 @@ -import { fetchUserModel } from "@instill-ai/toolkit/server"; -import { ImageResponse } from "next/og"; -// App router includes @vercel/og. -// No need to install it. - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url); - const modelName = searchParams.get("model"); - const userName = searchParams.get("user") || searchParams.get("amp;user"); - - const model = await fetchUserModel({ - modelName: `users/${userName}/models/${modelName}`, - accessToken: null, - }); - - return new ImageResponse( - ( -
-
-
- - {model.owner?.user?.id}/ - - {model?.id} - - -
-
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - {/* */} -
-
- ), - { - width: 1110, - height: 560, - } - ); -} From 2722ae5c5d5566f27cb8fed75421e1adb994e717 Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Mon, 20 May 2024 18:10:17 +0530 Subject: [PATCH 6/8] fix: build fix --- apps/console/src/app/api/pipeline/route.tsx | 13 ++++++++----- apps/console/src/app/api/user/route.tsx | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/console/src/app/api/pipeline/route.tsx b/apps/console/src/app/api/pipeline/route.tsx index 8a0f6c750d..b165b7e06e 100644 --- a/apps/console/src/app/api/pipeline/route.tsx +++ b/apps/console/src/app/api/pipeline/route.tsx @@ -1,4 +1,5 @@ import { fetchUserPipeline } from "@instill-ai/toolkit/server"; +import Image from "next/image"; import { ImageResponse } from "next/og"; // App router includes @vercel/og. // No need to install it. @@ -46,11 +47,13 @@ export async function GET(request: Request) {
- + {user?.profile ? ( + + ) : null}
diff --git a/apps/console/src/app/api/user/route.tsx b/apps/console/src/app/api/user/route.tsx index cc4f988c38..e5f554060d 100644 --- a/apps/console/src/app/api/user/route.tsx +++ b/apps/console/src/app/api/user/route.tsx @@ -1,6 +1,7 @@ // "use client"; import { fetchUser } from "@instill-ai/toolkit/server"; +import Image from "next/image"; import { ImageResponse } from "next/og"; // App router includes @vercel/og. // No need to install it. @@ -49,8 +50,8 @@ export async function GET(request: Request) {
- From 26bc1d4af9731a4da0baf366d1db2c4fa06430d5 Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Mon, 20 May 2024 18:33:48 +0530 Subject: [PATCH 7/8] fix: build fix --- apps/console/src/app/api/pipeline/route.tsx | 4 +--- apps/console/src/app/api/user/route.tsx | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/apps/console/src/app/api/pipeline/route.tsx b/apps/console/src/app/api/pipeline/route.tsx index b165b7e06e..1e92aafb91 100644 --- a/apps/console/src/app/api/pipeline/route.tsx +++ b/apps/console/src/app/api/pipeline/route.tsx @@ -1,8 +1,6 @@ import { fetchUserPipeline } from "@instill-ai/toolkit/server"; import Image from "next/image"; import { ImageResponse } from "next/og"; -// App router includes @vercel/og. -// No need to install it. export async function GET(request: Request) { const { searchParams } = new URL(request.url); @@ -167,6 +165,6 @@ export async function GET(request: Request) { { width: 1110, height: 560, - } + }, ); } diff --git a/apps/console/src/app/api/user/route.tsx b/apps/console/src/app/api/user/route.tsx index e5f554060d..1ee733c5bd 100644 --- a/apps/console/src/app/api/user/route.tsx +++ b/apps/console/src/app/api/user/route.tsx @@ -1,10 +1,6 @@ -// "use client"; - import { fetchUser } from "@instill-ai/toolkit/server"; import Image from "next/image"; import { ImageResponse } from "next/og"; -// App router includes @vercel/og. -// No need to install it. export async function GET(request: Request) { const { searchParams } = new URL(request.url); @@ -13,7 +9,6 @@ export async function GET(request: Request) { const user = await fetchUser({ userName: "users/" + userName, - // This is a public route, we don't need to request it with access token accessToken: null, }); @@ -169,6 +164,6 @@ export async function GET(request: Request) { { width: 1110, height: 560, - } + }, ); } From 4fb5992c08822f23e4901887bdb5ab9f711a1569 Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Mon, 20 May 2024 20:10:39 +0530 Subject: [PATCH 8/8] feat: update --- apps/console/src/app/api/pipeline/route.tsx | 3 +-- apps/console/src/app/api/user/route.tsx | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/apps/console/src/app/api/pipeline/route.tsx b/apps/console/src/app/api/pipeline/route.tsx index 1e92aafb91..8b1ef2f51d 100644 --- a/apps/console/src/app/api/pipeline/route.tsx +++ b/apps/console/src/app/api/pipeline/route.tsx @@ -1,5 +1,4 @@ import { fetchUserPipeline } from "@instill-ai/toolkit/server"; -import Image from "next/image"; import { ImageResponse } from "next/og"; export async function GET(request: Request) { @@ -46,7 +45,7 @@ export async function GET(request: Request) {
{user?.profile ? ( -
-