Skip to content

Commit

Permalink
Added TypeScript support for optional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
eldadfux committed Dec 23, 2020
1 parent 3f71ea1 commit 64cdc3e
Show file tree
Hide file tree
Showing 113 changed files with 1,257 additions and 143 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite Web SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-js.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1)

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
Use the Web SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
Expand Down Expand Up @@ -30,9 +30,24 @@ import * as Appwrite from "appwrite";
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:

```html
<script src="https://cdn.jsdelivr.net/npm/appwrite@1.1.0"></script>
<script src="https://cdn.jsdelivr.net/npm/appwrite@1.2.0"></script>
```

## Getting Started

Initialise the Appwrite SDK in your code, and setup your API credentials:

```js

// Init your Web SDK
var appwrite = new Appwrite();

appwrite
.setEndpoint('http://localhost/v1') // Set only when using self-hosted solution
.setProject('455x34dfkj') // Your Appwrite Project UID
;

```


## Contribution
Expand Down
9 changes: 3 additions & 6 deletions docs/examples/account/create-o-auth2session.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let promise = sdk.account.createOAuth2Session('bitbucket');
// Go to OAuth provider login page
sdk.account.createOAuth2Session('amazon');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
1 change: 1 addition & 0 deletions docs/examples/account/create-recovery.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-session.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-verification.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/delete-session.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/delete-sessions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/delete.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/get-logs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/get-prefs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/get-sessions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/get.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-email.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-name.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-password.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-prefs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-recovery.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-verification.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
9 changes: 3 additions & 6 deletions docs/examples/avatars/get-browser.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let promise = sdk.avatars.getBrowser('aa');
let result = sdk.avatars.getBrowser('aa');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
console.log(result); // Resource URL
3 changes: 2 additions & 1 deletion docs/examples/avatars/get-credit-card.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let result = sdk.avatars.getCreditCard('amex');

console.log(result); // Resource URL
console.log(result); // Resource URL
3 changes: 2 additions & 1 deletion docs/examples/avatars/get-favicon.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let result = sdk.avatars.getFavicon('https://example.com');

console.log(result); // Resource URL
console.log(result); // Resource URL
3 changes: 2 additions & 1 deletion docs/examples/avatars/get-flag.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let result = sdk.avatars.getFlag('af');

console.log(result); // Resource URL
console.log(result); // Resource URL
3 changes: 2 additions & 1 deletion docs/examples/avatars/get-image.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let result = sdk.avatars.getImage('https://example.com');

console.log(result); // Resource URL
console.log(result); // Resource URL
10 changes: 10 additions & 0 deletions docs/examples/avatars/get-initials.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let result = sdk.avatars.getInitials();

console.log(result); // Resource URL
3 changes: 2 additions & 1 deletion docs/examples/avatars/get-q-r.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let result = sdk.avatars.getQR('[TEXT]');

console.log(result); // Resource URL
console.log(result); // Resource URL
1 change: 1 addition & 0 deletions docs/examples/database/create-document.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/database/delete-document.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/database/get-document.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/database/list-documents.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
1 change: 1 addition & 0 deletions docs/examples/database/update-document.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Expand Down
10 changes: 10 additions & 0 deletions docs/examples/examples/account/create-o-auth2session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

// Go to OAuth provider login page
sdk.account.createOAuth2Session('amazon');

14 changes: 14 additions & 0 deletions docs/examples/examples/account/create-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let promise = sdk.account.createRecovery('email@example.com', 'https://example.com');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
14 changes: 14 additions & 0 deletions docs/examples/examples/account/create-session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let promise = sdk.account.createSession('email@example.com', 'password');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
14 changes: 14 additions & 0 deletions docs/examples/examples/account/create-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let promise = sdk.account.createVerification('https://example.com');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
14 changes: 14 additions & 0 deletions docs/examples/examples/account/create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let sdk = new Appwrite();

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

let promise = sdk.account.create('email@example.com', 'password');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
Loading

0 comments on commit 64cdc3e

Please sign in to comment.