-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo): add node js and ts demos
- Loading branch information
Showing
10 changed files
with
147 additions
and
10 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
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,16 @@ | ||
const { strapi } = require('@strapi/sdk-js'); | ||
|
||
async function main() { | ||
// Create the SDK instance | ||
const sdk = strapi({ baseURL: 'http://localhost:1337/api' }); | ||
|
||
// Create a collection type query manager for the categories | ||
const categories = sdk.collection('categories'); | ||
|
||
// Fetch the list of all categories | ||
const docs = await categories.find(); | ||
|
||
console.dir(docs, { depth: null }); | ||
} | ||
|
||
main().catch(console.error); |
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,20 @@ | ||
{ | ||
"name": "demo-node-javascript", | ||
"version": "1.0.0", | ||
"description": "A Strapi SDK demo using a Node x JavaScript application", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js", | ||
"debug": "DEBUG=* node index.js" | ||
}, | ||
"dependencies": { | ||
"@strapi/sdk-js": "link:../.." | ||
}, | ||
"keywords": [], | ||
"author": { | ||
"name": "Strapi Solutions SAS", | ||
"email": "[email protected]", | ||
"url": "https://strapi.io" | ||
}, | ||
"license": "ISC" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "demo-node-typescript", | ||
"version": "1.0.0", | ||
"description": "A Strapi SDK demo using a Node x TypeScript application", | ||
"main": "dist/index.js", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json", | ||
"watch": "tsc -p tsconfig.json -w", | ||
"start": "node dist/index.js", | ||
"debug": "DEBUG=* node dist/index.js" | ||
}, | ||
"dependencies": { | ||
"@strapi/sdk-js": "link:../.." | ||
}, | ||
"devDependencies": { | ||
"typescript": "5.7.3" | ||
}, | ||
"keywords": [], | ||
"author": { | ||
"name": "Strapi Solutions SAS", | ||
"email": "[email protected]", | ||
"url": "https://strapi.io" | ||
}, | ||
"license": "ISC" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { strapi } from '@strapi/sdk-js'; | ||
|
||
// Create the SDK instance | ||
const sdk = strapi({ baseURL: 'http://localhost:1337/api' }); | ||
|
||
// Create a collection type query manager for the categories | ||
const categories = sdk.collection('categories'); | ||
|
||
// Fetch the list of all categories | ||
const docs = await categories.find(); | ||
|
||
console.dir(docs, { depth: null }); |
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,26 @@ | ||
{ | ||
"compilerOptions": { | ||
/* Language and Environment */ | ||
"allowSyntheticDefaultImports": true, | ||
|
||
/* Modules */ | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "NodeNext", | ||
|
||
/* Emit */ | ||
"moduleResolution": "NodeNext", | ||
|
||
/* Interop Constraints */ | ||
|
||
"outDir": "./dist", | ||
"rootDir": "./src", | ||
"skipLibCheck": false, | ||
|
||
/* Type Checking */ | ||
"strict": true, | ||
|
||
/* Completeness */ | ||
"target": "ESNext" | ||
} | ||
} |
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