-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update-academy/monetizing-your-actor
- Loading branch information
Showing
19 changed files
with
184 additions
and
455 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,6 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ token: 'my-token' }); | ||
const { items } = await apifyClient.actors().list(); | ||
|
||
console.log(items); | ||
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,6 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ token: 'my-token' }); | ||
const myActor = await apifyClient.actors().create({ name: 'my-actor' }); | ||
|
||
console.log(myActor); | ||
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,59 @@ | ||
const { existsSync } = require('fs'); | ||
const path = require('path'); | ||
|
||
const X_CODE_SAMPLES_PROPERTY = 'x-codeSamples'; | ||
|
||
const LANGUAGES = [ | ||
{ lang: 'JavaScript', label: 'JS client' }, | ||
]; | ||
|
||
/** | ||
* This decorator adds the x-codeSamples property to the schema object if a file with the operationId exists in the | ||
* code samples directory. | ||
* This helps us add the samples in a consistent way and find out which operations are missing a sample. | ||
* | ||
* The added sample link will look like this: | ||
* x-codeSamples: | ||
* - lang: JavaScript | ||
* label: JS client | ||
* source: | ||
* $ref: ../../code_samples/js/acts_post.js | ||
*/ | ||
function CodeSamplesDecorator(target) { | ||
if (!target.operationId) return; | ||
|
||
const codeSamples = []; | ||
|
||
for (const { lang, label } of LANGUAGES) { | ||
const codeSamplePath = path.join(__dirname, `../../openapi/code_samples/${lang.toLowerCase()}/${target.operationId}.js`); | ||
|
||
if (!existsSync(codeSamplePath)) { | ||
// Just use this console log in development to see which operations are missing a code sample. | ||
// console.log(`Missing code sample for operation ${target.operationId}`); | ||
return; | ||
} | ||
|
||
codeSamples.push({ | ||
lang, | ||
label, | ||
source: { | ||
$ref: codeSamplePath, | ||
}, | ||
}); | ||
} | ||
|
||
if (codeSamples.length) { | ||
target[X_CODE_SAMPLES_PROPERTY] = codeSamples; | ||
} | ||
} | ||
|
||
module.exports = () => ({ | ||
// Redocly is using a visitor pattern. What the following code does is that whenever the traverser leaves a node of | ||
// type Tag or Operation, it executes CodeSamplesDecorator on it. | ||
Tag: { | ||
leave: CodeSamplesDecorator, | ||
}, | ||
Operation: { | ||
leave: CodeSamplesDecorator, | ||
}, | ||
}); |
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
97 changes: 0 additions & 97 deletions
97
sources/academy/platform/get_most_of_actors/actor_readme.md
This file was deleted.
Oops, something went wrong.
111 changes: 0 additions & 111 deletions
111
sources/academy/platform/get_most_of_actors/guidelines_for_writing.md
This file was deleted.
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
Oops, something went wrong.