Skip to content

Commit

Permalink
Merge pull request #846 from appwrite/feat-improve-code-fence
Browse files Browse the repository at this point in the history
Make it obvious when we talk about the Client SDKs
  • Loading branch information
ArmanNik authored Apr 15, 2024
2 parents 370da9f + f1b5856 commit 2354eba
Show file tree
Hide file tree
Showing 81 changed files with 685 additions and 706 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ It is possible to enhance accessibility through development as well. In collabor

Browsers have a default font size that users can change via the browser setting. A pixel is an absolute unit for fixed sizes and spaces that ignores browser settings. This means that if we are using pixels and a user (with or without vision impairment) changes the font size in their browser settings, their setting won't affect our product. That being said, pixels should not cause any problems if the user zooms in, but we make no assumptions about users' preferences. This is why we decided to define the font size in REM, which is a relative unit.

```js
```client-web
import { Client, Account } from "appwrite";

const client = new Client()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ One great aspect of Appwrite 2FA is that it can be used in conjunction with any

To use 2FA, it needs to be enabled on a user’s account. This can be achieved by calling `account.updateMFA()`.

```js
```client-web
import { Client, Account } from "appwrite";

// Init SDK
Expand Down
2 changes: 1 addition & 1 deletion src/routes/blog/post/enhancing-type-safety/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Code maintainability is extremely important for any piece of software, which is

With the latest release of Appwrite, we have taken steps to improve type safety within our SDKs by leveraging enums. We have replaced all magic literals, such as constants needed for OAuth adapters, with enums to simplify the developer experience for all those who are building with Appwrite.

```js
```client-web
import { Client, Account, OAuthProvider } from "appwrite";

const client = new Client()
Expand Down
2 changes: 1 addition & 1 deletion src/routes/blog/post/enums-api-design/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ By being aware of these pitfalls and employing strategies to avoid them, you can

With the latest release of Appwrite, we have taken steps to improve type safety within our SDKs by leveraging enums. We have replaced all magic literals, such as constants needed for OAuth adapters, with enums to simplify the developer experience and make it less error-prone for all those who are building with Appwrite. This change exemplifies our commitment to robust and user-friendly API design.

```js
```client-web
import { Client, Account, OAuthProvider } from "appwrite";

const client = new Client()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Magic URL authentication is a two-step process in Appwrite.

First, we initialize the login process by sending an email with the magic URL. If the email has never been used, a new account is also generated.

```js
```client-web
import { Client, Account, ID } from "appwrite";

const client = new Client()
Expand Down Expand Up @@ -99,7 +99,7 @@ Email OTP authentication is a two-step process in Appwrite.

First, we initialize the login process by sending an email. If the email has never been used, a new account is also generated.

```js
```client-web
import { Client, Account, ID } from "appwrite";

const client = new Client()
Expand Down Expand Up @@ -134,7 +134,7 @@ Phone authentication is a two-step process in Appwrite.

First, we initialize the login process by sending an SMS. If the phone number has never been used, a new account is also generated.

```dart
```client-flutter
import 'package:appwrite/appwrite.dart';

final client = Client()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This new feature, however, ensures you can use more readable and self-documentin

Bringing along benefits such as massively reducing friction when using routes that have predefined parameters. One of the most common examples of SDK Enums is OAuth providers. To log in with Apple, you must pass the `apple` string as the provider. With enums, you'll be able to pass `OAuthProvider.Apple` instead.

```js
```client-web
import { Client, Account, OAuthProvider } from "appwrite";

const client = new Client()
Expand Down
2 changes: 1 addition & 1 deletion src/routes/blog/post/oauth-openid/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Appwrite provides the necessary redirect URL to add to your OIDC app configurati

Once that is done, you can use any of the Appwrite client SDKs to implement OAuth 2.0 or OIDC authentication in just a few lines of code.

```js
```client-web
import { Client, Account, OAuthProvider } from "appwrite";

const client = new Client()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ PBKDF2 is a widely-used password hashing algorithm that iteratively applies a ps

Appwrite Authentication also leverages password hashing algorithms to allow developers to secure their users’ passwords via password hashing algorithms. Appwrite uses the `Argon2id` algorithm to hash the password when a user creates an account from a client-side application. Appwrite’s SDKs offer a simple abstraction for the Appwrite Accounts API to let developers implement this, like the following example:

```js
```client-web
import { Client, Account, ID } from "appwrite";

const client = new Client()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The content of the messages plays a crucial role. Here are some best practices t

The newly released Appwrite Messaging substantially simplifies your process of sending out push notifications to your application’s users. We have added simple-to-use adapters for Firebase Cloud Messaging (FCM) and Apple Push Notification Service (APNS) to let you send push notifications to let you send push notifications to both Android and iOS users.

```js
```server-nodejs
const sdk = require('node-appwrite');

// Init SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Here's an overview of the Twilio Programmable Messaging:

As a part of our latest release, Appwrite 1.5, we have launched a new product, Messaging, that helps developers implement communication services within their applications. As a part of the SMS offering within Messaging, we have added an adapter to integrate Twilio Programmable Messaging with Appwrite. Once you have access to your account SID, auth token, and phone number from Twilio, you will be able to send messages to your users with just a few lines of code.

```js
```server-nodejs
const sdk = require('node-appwrite');

// Init SDK
Expand Down
2 changes: 1 addition & 1 deletion src/routes/blog/post/understand-data-queries/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ One of the data retrieval APIs the Appwrite Database offers is a list documents
- `OR` operation: This operator allows nesting queries in an OR condition.
- `CONTAINS` operation: The contains operator allows filtering by values that are contained in an array.

```js
```client-web
import { Client, Databases, Query } from "appwrite";

const client = new Client()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The original function provided through this template used OpenAI’s GPT-3.5-Tur

After that is done, we need to visit the `src/main.js` file and replace the existing code with the following:

```js
```client-web
import { OpenAI } from 'openai';
import { getStaticFile, throwIfMissing } from './utils.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ You can send messages in different languages by setting the locale with `client.
For example, you can send an email verification in French.

{% multicode %}
```js
```client-web
import { Client, Account } from "appwrite";

const client = new Client();
Expand All @@ -144,7 +144,7 @@ promise.then(function (response) {
});
```

```dart
```client-flutter
import 'package:appwrite/appwrite.dart';

void main() { // Init SDK
Expand All @@ -167,7 +167,7 @@ void main() { // Init SDK
}
```

```kotlin
```client-android-kotlin
import io.appwrite.Client
import io.appwrite.services.Account

Expand All @@ -181,7 +181,7 @@ val account = Account(client)
val response = account.createVerification('https://example.com')
```

```swift
```client-apple
import Appwrite

let client = Client()
Expand Down
4 changes: 2 additions & 2 deletions src/routes/docs/advanced/platform/permissions/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The following examples are using the [Appwrite Web SDK](https://github.com/appwr

In the following example, we are creating a document that can be read by anyone, edited by writers or admins, and deleted by administrators or a user with the user ID `user:5c1f88b42259e`.

```js
```client-web
import { Client, Databases, Permission, Role } from "appwrite";

const client = new Client()
Expand Down Expand Up @@ -100,7 +100,7 @@ promise.then(function (response) {

In the following example, we are creating a document that can be read by members of the team with ID `5c1f88b87435e` and can only be edited or deleted by members of the same team that possess the team role `owner`.

```js
```client-web
import { Client, Databases, Permission, Role } from "appwrite";

const client = new Client()
Expand Down
82 changes: 41 additions & 41 deletions src/routes/docs/apis/graphql/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ This allows you to execute complex actions in a single network request.
Appwrite SDKs also support GraphQL in addition to the REST services.

{% multicode %}
```js
```client-web
import { Client, Graphql } from "appwrite";

const client = new Client()
Expand Down Expand Up @@ -266,7 +266,7 @@ mutation.then(response => {
console.log(error);
});
```
```dart
```client-flutter
import 'package:appwrite/appwrite.dart';

final client = Client()
Expand Down Expand Up @@ -303,45 +303,7 @@ mutation.then((response) {
print(error.message);
});
```
```kotlin
import io.appwrite.Client
import io.appwrite.services.Graphql

val client = Client(context)
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<PROJECT_ID>") // Your project ID

val graphql = Graphql(client)

try {
val response = graphql.mutation(mapOf(
"query" to """mutation CreateAccount(
${'$'}email: String!,
${'$'}password: String!,
${'$'}name: String
) {
accountCreate(
email: ${'$'}email,
password: ${'$'}password,
name: ${'$'}name,
userId: "unique()"
) {
_id
}
}""",
"variables" to mapOf(
"email" to "...",
"password" to "...",
"name" to "..."
)
))

Log.d(javaClass.name, response)
} catch (ex: AppwriteException) {
ex.printStackTrace()
}
```
```swift
```client-apple
import Appwrite

let client = Client()
Expand Down Expand Up @@ -381,4 +343,42 @@ do {
print(error.localizedDescription)
}
```
```client-android-kotlin
import io.appwrite.Client
import io.appwrite.services.Graphql

val client = Client(context)
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<PROJECT_ID>") // Your project ID

val graphql = Graphql(client)

try {
val response = graphql.mutation(mapOf(
"query" to """mutation CreateAccount(
${'$'}email: String!,
${'$'}password: String!,
${'$'}name: String
) {
accountCreate(
email: ${'$'}email,
password: ${'$'}password,
name: ${'$'}name,
userId: "unique()"
) {
_id
}
}""",
"variables" to mapOf(
"email" to "...",
"password" to "...",
"name" to "..."
)
))

Log.d(javaClass.name, response)
} catch (ex: AppwriteException) {
ex.printStackTrace()
}
```
{% /multicode %}
Loading

0 comments on commit 2354eba

Please sign in to comment.