docs: Use JS highlighter instead of TS

This commit is contained in:
Faruk AYDIN
2024-01-15 12:56:43 +01:00
parent 476aa6e3aa
commit 5a1960609a
5 changed files with 25 additions and 25 deletions

View File

@@ -18,7 +18,7 @@ The build integrations section is best understood when read from beginning to en
Open the `thecatapi/index.ts` file and add the highlighted lines for actions.
```typescript{4,17}
```javascript{4,17}
import defineApp from '../../helpers/define-app';
import auth from './auth';
import triggers from './triggers';
@@ -43,7 +43,7 @@ export default defineApp({
Create the `actions/index.ts` file inside of the `thecatapi` folder.
```typescript
```javascript
import markCatImageAsFavorite from './mark-cat-image-as-favorite';
export default [markCatImageAsFavorite];
@@ -57,7 +57,7 @@ If you add new actions, you need to add them to the actions/index.ts file and ex
Create the `actions/mark-cat-image-as-favorite/index.ts` file inside the `thecatapi` folder.
```typescript
```javascript
import defineAction from '../../../../helpers/define-action';
export default defineAction({
@@ -93,7 +93,7 @@ Let's briefly explain what we defined here.
Open the `actions/mark-cat-image-as-favorite.ts` file and add the highlighted lines.
```typescript{7-20}
```javascript{7-20}
import defineAction from '../../../../helpers/define-action';
export default defineAction({

View File

@@ -36,7 +36,7 @@ touch index.ts
Then let's define the app inside of the `index.ts` file as follows:
```typescript
```javascript
import defineApp from '../../helpers/define-app';
export default defineApp({

View File

@@ -26,7 +26,7 @@ You can find detailed documentation of the cat API [here](https://docs.thecatapi
Open the `thecatapi/index.ts` file and add the highlighted lines for authentication.
```typescript{2,13}
```javascript{2,13}
import defineApp from '../../helpers/define-app';
import auth from './auth';
@@ -54,7 +54,7 @@ touch auth/index.ts
Then let's start with defining fields the auth inside of the `auth/index.ts` file as follows:
```typescript
```javascript
export default {
fields: [
{
@@ -103,7 +103,7 @@ So until now, we integrated auth folder with the app definition and defined the
Start with adding the `verifyCredentials` method to the `auth/index.ts` file.
```typescript{1,8}
```javascript{1,8}
import verifyCredentials from './verify-credentials';
export default {
@@ -117,7 +117,7 @@ export default {
Let's create the `verify-credentials.ts` file inside the `auth` folder.
```typescript
```javascript
const verifyCredentials = async ($: IGlobalVariable) => {
// TODO: Implement verification of the credentials
};
@@ -129,7 +129,7 @@ We generally use the `users/me` endpoint or any other endpoint that we can valid
Let's implement the authentication logic that we mentioned above in the `verify-credentials.ts` file.
```typescript
```javascript
const verifyCredentials = async ($: IGlobalVariable) => {
await $.http.get('/v1/images/search');
@@ -153,7 +153,7 @@ We have implemented the `verifyCredentials` method. Now we need to check whether
Start with adding the `isStillVerified` method to the `auth/index.ts` file.
```typescript{2,10}
```javascript{2,10}
import verifyCredentials from './verify-credentials';
import isStillVerified from './is-still-verified';
@@ -169,7 +169,7 @@ export default {
Let's create the `is-still-verified.ts` file inside the `auth` folder.
```typescript
```javascript
import verifyCredentials from './verify-credentials';
const isStillVerified = async ($: IGlobalVariable) => {

View File

@@ -20,7 +20,7 @@ The global variable is represented as `$` variable in the codebase, and it's a J
## $.auth.set
```typescript
```javascript
await $.auth.set({
key: 'value',
});
@@ -30,7 +30,7 @@ It's used to set the authentication data, and you can use this method with multi
## $.auth.data
```typescript
```javascript
$.auth.data; // { key: 'value' }
```
@@ -38,7 +38,7 @@ It's used to retrieve the authentication data that we set with `$.auth.set()`. T
## $.app.baseUrl
```typescript
```javascript
$.app.baseUrl; // https://thecatapi.com
```
@@ -46,7 +46,7 @@ It's used to retrieve the base URL of the app that we defined previously. In our
## $.app.apiBaseUrl
```typescript
```javascript
$.app.apiBaseUrl; // https://api.thecatapi.com
```
@@ -54,7 +54,7 @@ It's used to retrieve the API base URL of the app that we defined previously. In
## $.app.auth.fields
```typescript
```javascript
$.app.auth.fields;
```
@@ -64,7 +64,7 @@ It's used to retrieve the fields that we defined in the `auth` section of the ap
It's an HTTP client to be used for making HTTP requests. It's a wrapper around the [axios](https://axios-http.com) library. We use this property when we need to make HTTP requests to the third-party service. The `apiBaseUrl` field we set up in the app will be used as the base URL for the HTTP requests. For example, to search the cat images, we can use the following code:
```typescript
```javascript
await $.http.get('/v1/images/search?order=DESC', {
headers: {
'x-api-key': $.auth.data.apiKey,
@@ -76,7 +76,7 @@ Keep in mind that the HTTP client handles the error with the status code that fa
## $.step.parameters
```typescript
```javascript
$.step.parameters; // { key: 'value' }
```
@@ -84,7 +84,7 @@ It refers to the parameters that are set by users in the UI. We use this propert
## $.pushTriggerItem
```typescript
```javascript
$.pushTriggerItem({
raw: resourceData,
meta: {
@@ -97,7 +97,7 @@ It's used to push trigger data to be processed by Automatisch. It must reflect t
## $.setActionItem
```typescript
```javascript
$.setActionItem({
raw: resourceData,
});

View File

@@ -22,7 +22,7 @@ We used a polling-based HTTP trigger in our example but if you need to use a web
Open the `thecatapi/index.ts` file and add the highlighted lines for triggers.
```typescript{3,15}
```javascript{3,15}
import defineApp from '../../helpers/define-app';
import auth from './auth';
import triggers from './triggers';
@@ -45,7 +45,7 @@ export default defineApp({
Create the `triggers/index.ts` file inside of the `thecatapi` folder.
```typescript
```javascript
import searchCatImages from './search-cat-images';
export default [searchCatImages];
@@ -59,7 +59,7 @@ If you add new triggers, you need to add them to the `triggers/index.ts` file an
Create the `triggers/search-cat-images/index.ts` file inside of the `thecatapi` folder.
```typescript
```javascript
import defineTrigger from '../../../../helpers/define-trigger';
export default defineTrigger({
@@ -93,7 +93,7 @@ Let's briefly explain what we defined here.
Implement the `run` function by adding highlighted lines.
```typescript{1,7-30}
```javascript{1,7-30}
import defineTrigger from '../../../../helpers/define-trigger';
export default defineTrigger({