diff --git a/app/routes/schema/$.ts b/app/routes/schema/$.ts index 6730c6fea..8d31c70a4 100644 --- a/app/routes/schema/$.ts +++ b/app/routes/schema/$.ts @@ -5,36 +5,12 @@ * * SPDX-License-Identifier: NASA-1.3 */ -import '@nasa-gcn/schema' -import type { DataFunctionArgs } from '@remix-run/node' -import { readFile } from 'node:fs/promises' -import { dirname, extname, join } from 'node:path' - -function isErrnoException(e: unknown): e is NodeJS.ErrnoException { - return e instanceof Error && 'code' in e && 'errno' in e -} +import { type DataFunctionArgs, redirect } from '@remix-run/node' /* Make all JSON files at https://github.com/nasa-gcn/gcn-schema available from * https://gcn.nasa.gov/schema */ -export async function loader({ params: { '*': subPath } }: DataFunctionArgs) { - if (!subPath) throw new Error('path must be defined') - - if (extname(subPath) !== '.json') - throw new Response('not found', { status: 404 }) - - const path = join(dirname(require.resolve('@nasa-gcn/schema')), subPath) - - let body - try { - body = await readFile(path, { - encoding: 'utf-8', - }) - } catch (e) { - if (isErrnoException(e) && e.code === 'ENOENT') { - throw new Response('Not found', { status: 404 }) - } - throw e - } - - return new Response(body, { headers: { 'Content-Type': 'application/json' } }) +export async function loader({ params: { '*': path } }: DataFunctionArgs) { + return redirect( + `https://raw.githubusercontent.com/nasa-gcn/gcn-schema/main/${path ?? ''}` + ) } diff --git a/package-lock.json b/package-lock.json index 8e66c8c9f..f8d03594f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "@balavishnuvj/remix-seo": "^1.0.2", "@nasa-gcn/architect-functions-search": "^0.2.0", "@nasa-gcn/dynamodb-autoincrement": "^0.0.6", - "@nasa-gcn/schema": "github:nasa-gcn/gcn-schema", "@octokit/rest": "^19.0.7", "@opensearch-project/opensearch": "^2.2.0", "@remix-run/architect": "^1.15.0", @@ -14132,9 +14131,6 @@ "node": ">=16" } }, - "node_modules/@nasa-gcn/schema": { - "resolved": "git+ssh://git@github.com/nasa-gcn/gcn-schema.git#5cdb482e8baa689c9a0c487ef9c4a85589d90b85" - }, "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { "version": "5.1.1-v1", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", @@ -46901,10 +46897,6 @@ "resolved": "https://registry.npmjs.org/@nasa-gcn/dynamodb-autoincrement/-/dynamodb-autoincrement-0.0.6.tgz", "integrity": "sha512-+ecRUXHcGEqHGxhe5I1ApEAN745uauKpRfQliRMM6RK/NZNm0jDHfh9y63dRCuzunMWfVga4z3MB9gVkeUkLVw==" }, - "@nasa-gcn/schema": { - "version": "git+ssh://git@github.com/nasa-gcn/gcn-schema.git#5cdb482e8baa689c9a0c487ef9c4a85589d90b85", - "from": "@nasa-gcn/schema@github:nasa-gcn/gcn-schema" - }, "@nicolo-ribaudo/eslint-scope-5-internals": { "version": "5.1.1-v1", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", diff --git a/package.json b/package.json index bb6418620..298b4f5d7 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "@balavishnuvj/remix-seo": "^1.0.2", "@nasa-gcn/architect-functions-search": "^0.2.0", "@nasa-gcn/dynamodb-autoincrement": "^0.0.6", - "@nasa-gcn/schema": "github:nasa-gcn/gcn-schema", "@octokit/rest": "^19.0.7", "@opensearch-project/opensearch": "^2.2.0", "@remix-run/architect": "^1.15.0",