-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from open-rpc/fix/web-support
fix: add browser support
- Loading branch information
Showing
12 changed files
with
222 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { OpenRPC } from "@open-rpc/meta-schema"; | ||
import { readJson } from "fs-extra"; | ||
import { TGetOpenRPCDocument } from "./get-open-rpc-document"; | ||
|
||
const readSchemaFromFile: TGetOpenRPCDocument = async (filePath: string) => { | ||
try { | ||
return await readJson(filePath) as OpenRPC; | ||
} catch (e) { | ||
if (e.message.includes("SyntaxError")) { | ||
throw new Error(`Failed to parse json in file ${filePath}`); | ||
} else { | ||
throw new Error(`Unable to read openrpc.json file located at ${filePath}`); | ||
} | ||
} | ||
}; | ||
|
||
export default readSchemaFromFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { OpenRPC } from "@open-rpc/meta-schema"; | ||
import fetch from "isomorphic-fetch"; | ||
import { TGetOpenRPCDocument } from "./get-open-rpc-document"; | ||
|
||
const fetchUrlSchema: TGetOpenRPCDocument = async (schema) => { | ||
try { | ||
const response = await fetch(schema); | ||
return await response.json() as OpenRPC; | ||
} catch (e) { | ||
throw new Error(`Unable to download openrpc.json file located at the url: ${schema}`); | ||
} | ||
}; | ||
|
||
export default fetchUrlSchema; |
Oops, something went wrong.