From cba8e0489160410170277c94f882cab6047c2605 Mon Sep 17 00:00:00 2001 From: eveeifyeve Date: Sat, 27 Jul 2024 01:46:48 +1000 Subject: [PATCH] feat: configSchema --- package.json | 117 +++++++++++++++++---------------- src/pages/configSchema.json.ts | 33 ++++++++++ 2 files changed, 92 insertions(+), 58 deletions(-) create mode 100644 src/pages/configSchema.json.ts diff --git a/package.json b/package.json index c50a94c..ea5d909 100644 --- a/package.json +++ b/package.json @@ -1,60 +1,61 @@ { - "name": "teaclient-website", - "type": "module", - "version": "0.0.2", - "scripts": { - "dev": "astro dev", - "preview": "astro preview", - "build": "astro build", - "astro": "astro", - "lint": "biome check --apply . && stylelint 'src/styles/**/*.css' --fix", - "fmt": "biome format ./ --write", - "biome": "bunx @biomejs/biome", - "check": "biome check ./ && stylelint 'src/styles/**/*.css' && bun astro check && bun test" - }, - "trustedDependencies": ["sharp"], - "stylelint": { - "extends": "stylelint-config-standard", - "plugins": ["stylelint-scss"], - "customSyntax": "postcss-scss", - "rules": { - "at-rule-no-unknown": null, - "selector-class-pattern": null, - "scss/at-rule-no-unknown": true, - "custom-property-pattern": null - } - }, - "commitlint": { - "extends": ["@commitlint/config-conventional"] - }, - "dependencies": { - "@astrojs/mdx": "^2.0.2", - "@astrojs/rss": "^4.0.5", - "@astrojs/sitemap": "^3.1.1", - "@astrojs/tailwind": "^5.1.0", - "@astrojs/ts-plugin": "^1.3.1", - "astro-meta-tags": "^0.2.1", - "astro-page-insight": "^0.6.1", - "astro-seo": "^0.8.0", - "axios": "^1.6.5", - "sass": "^1.71.1", - "sharp": "^0.33.2", - "tailwind-merge": "^2.2.1", - "tailwindcss": "^3.4.1", - "web-vitals": "^3.5.0" - }, - "devDependencies": { - "@astrojs/check": "^0.5.10", - "@biomejs/biome": "^1.5.3", - "@types/bun": "^1.0.12", - "astro": "^4.2.3", - "happy-dom": "^14.7.1", - "playwright": "^1.43.1", - "postcss-scss": "^4.0.9", - "stylelint": "^16.3.1", - "stylelint-config-standard": "^36.0.0", - "stylelint-scss": "^6.2.1", - "typescript": "^5.2.2" - }, - "packageManager": "bun@1.0.25" + "name": "teaclient-website", + "type": "module", + "version": "0.0.2", + "scripts": { + "dev": "astro dev", + "preview": "astro preview", + "build": "astro build", + "astro": "astro", + "lint": "biome check --apply . && stylelint 'src/styles/**/*.css' --fix", + "fmt": "biome format ./ --write", + "biome": "bunx @biomejs/biome", + "check": "biome check ./ && stylelint 'src/styles/**/*.css' && bun astro check && bun test" + }, + "trustedDependencies": ["sharp"], + "stylelint": { + "extends": "stylelint-config-standard", + "plugins": ["stylelint-scss"], + "customSyntax": "postcss-scss", + "rules": { + "at-rule-no-unknown": null, + "selector-class-pattern": null, + "scss/at-rule-no-unknown": true, + "custom-property-pattern": null + } + }, + "commitlint": { + "extends": ["@commitlint/config-conventional"] + }, + "dependencies": { + "@astrojs/mdx": "^2.0.2", + "@astrojs/rss": "^4.0.5", + "@astrojs/sitemap": "^3.1.1", + "@astrojs/tailwind": "^5.1.0", + "@astrojs/ts-plugin": "^1.3.1", + "astro-meta-tags": "^0.2.1", + "astro-page-insight": "^0.6.1", + "astro-seo": "^0.8.0", + "axios": "^1.6.5", + "octokit": "^4.0.2", + "sass": "^1.71.1", + "sharp": "^0.33.2", + "tailwind-merge": "^2.2.1", + "tailwindcss": "^3.4.1", + "web-vitals": "^3.5.0" + }, + "devDependencies": { + "@astrojs/check": "^0.5.10", + "@biomejs/biome": "^1.5.3", + "@types/bun": "^1.0.12", + "astro": "^4.2.3", + "happy-dom": "^14.7.1", + "playwright": "^1.43.1", + "postcss-scss": "^4.0.9", + "stylelint": "^16.3.1", + "stylelint-config-standard": "^36.0.0", + "stylelint-scss": "^6.2.1", + "typescript": "^5.2.2" + }, + "packageManager": "bun@1.0.25" } diff --git a/src/pages/configSchema.json.ts b/src/pages/configSchema.json.ts new file mode 100644 index 0000000..2720a32 --- /dev/null +++ b/src/pages/configSchema.json.ts @@ -0,0 +1,33 @@ +import { Octokit } from "octokit"; + +export const GET = async () => { + let octokit = new Octokit({ + auth: import.meta.env.GITHUB_TOKEN, + }); + + try { + let data = await octokit.request('GET /repos/{owner}/{repo}/releases/latest', { + owner: 'TeaClientMC', + repo: 'ConfigSchema', + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }); + + // Access the assets array from the response + const assets = data.data.assets; + + // Find the JSON file and get its download URL + const jsonFileUrl = assets.find(asset => asset.name === 'configschema.json').browser_download_url; + + // Download the JSON file content + const response = await fetch(jsonFileUrl); + const jsonContent = await response.text(); + + // Return the JSON content + return new Response(jsonContent); + } catch (error) { + console.error("Error fetching config schema:", error); + return new Response(JSON.stringify({ error: "Failed to load config schema" }), { status: 500 }); + } +}; \ No newline at end of file