mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-07-13 02:25:10 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
c392b27cac | |||
dc5e41a638 | |||
09d8b28a66
|
31
README.md
31
README.md
@ -63,19 +63,40 @@ _Note: a complete documentation is available at [TCGdex.dev](https://www.tcgdex.
|
||||
|
||||
**Example: Fetch a Card**
|
||||
|
||||
_in Browser_
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tcgdex/sdk@2.4.9/dist/tcgdex.browser.js"></script>
|
||||
<script>
|
||||
// Instantiate the SDK
|
||||
const tcgdex = new TCGdex('en');
|
||||
|
||||
// go into an async context
|
||||
;(async () => {
|
||||
// Card will be Furret from the Darkness Ablaze Set
|
||||
const card = await tcgdex.fetch('cards', 'swsh3-136');
|
||||
})();
|
||||
</script>
|
||||
```
|
||||
|
||||
_in NodeJS (in an async context)_
|
||||
|
||||
```typescript
|
||||
// Import the SDK in Typescript
|
||||
import TCGdex from '@tcgdex/sdk';
|
||||
|
||||
// Instantiate the SDK
|
||||
// note: you can use one of the following lanugages
|
||||
const tcgdex = new TCGdex('en');
|
||||
|
||||
// Card will be Furret from the Darkness Ablaze Set
|
||||
const card = await tcgdex.fetch('cards', 'swsh3-136');
|
||||
// go into an async context
|
||||
(async () => {
|
||||
// Card will be Furret from the Darkness Ablaze Set
|
||||
const card = await tcgdex.fetch('cards', 'swsh3-136');
|
||||
|
||||
// You can also get the same result using
|
||||
const card = await tcgdex.fetch('sets', 'Darkness Ablaze', 136);
|
||||
})();
|
||||
|
||||
// You can also get the same result using
|
||||
const card = await tcgdex.fetch('sets', 'Darkness Ablaze', 136);
|
||||
```
|
||||
|
||||
**Other Examples**
|
||||
|
1836
package-lock.json
generated
1836
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@ -1,9 +1,21 @@
|
||||
{
|
||||
"name": "@tcgdex/sdk",
|
||||
"version": "2.4.9",
|
||||
"main": "./dist/cjs/tcgdex.node.js",
|
||||
"module": "./dist/modules/tcgdex.node.js",
|
||||
"types": "./dist/types/tcgdex.d.ts",
|
||||
"version": "2.5.0",
|
||||
"main": "./dist/tcgdex.node.js",
|
||||
"module": "./dist/tcgdex.node.mjs",
|
||||
"types": "./dist/tcgdex.node.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./dist/tcgdex.node.d.ts",
|
||||
"default": "./dist/tcgdex.node.js"
|
||||
},
|
||||
"import": {
|
||||
"default": "./dist/tcgdex.node.mjs",
|
||||
"types": "./dist/tcgdex.node.d.mts"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Communicate with the Open Source TCGdex API in Javascript/Typescript using the SDK",
|
||||
"repository": "https://github.com/tcgdex/javascript-sdk.git",
|
||||
"homepage": "https://github.com/tcgdex/javascript-sdk",
|
||||
@ -29,10 +41,10 @@
|
||||
"@types/node-fetch": "^2",
|
||||
"@typescript-eslint/eslint-plugin": "^5",
|
||||
"@typescript-eslint/parser": "^5",
|
||||
"esbuild": "^0.16.3",
|
||||
"eslint": "^8",
|
||||
"jest": "^29",
|
||||
"typescript": "^4"
|
||||
"tsup": "^7",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
@ -43,10 +55,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"prebuild": "node scripts/export-version-number.js",
|
||||
"build": "npm run build:cjs && npm run build:browser && npm run build:es2015",
|
||||
"build:cjs": "tsc --project tsconfig.json",
|
||||
"build:es2015": "tsc --project tsconfig.es2015.json",
|
||||
"build:browser": "esbuild ./src/tcgdex.browser.ts --bundle --minify --sourcemap --target=es2016,chrome90,firefox78,safari14,ios13,edge90 --outfile=dist/tcgdex.browser.js",
|
||||
"build": "tsup ./src/tcgdex.node.ts --format cjs,esm --dts --clean && tsup ./src/tcgdex.browser.ts --format iife --minify --sourcemap",
|
||||
"prepublishOnly": "npm run build",
|
||||
"lint": "eslint",
|
||||
"test": "jest --coverage"
|
||||
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["./src/tcgdex.node.ts"],
|
||||
"compilerOptions": {
|
||||
"target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "ES2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
"declaration": false, /* Generates corresponding '.d.ts' file. */
|
||||
"declarationDir": null,
|
||||
"outDir": "./dist/modules", /* Redirect output structure to the directory. */
|
||||
}
|
||||
}
|
@ -2,14 +2,7 @@
|
||||
"extends": "./node_modules/@dzeio/config/tsconfig.base",
|
||||
"include": ["./src/tcgdex.node.ts"],
|
||||
"compilerOptions": {
|
||||
|
||||
"target": "ES2015",
|
||||
|
||||
"declaration": true,
|
||||
"declarationDir": "./dist/types",
|
||||
|
||||
"outDir": "./dist/cjs",
|
||||
"rootDir": "./src",
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user