appwrite
Advanced tools
Comparing version 1.0.23 to 1.0.24
@@ -7,3 +7,3 @@ let sdk = new Appwrite(); | ||
let promise = sdk.auth.login('email@example.com', 'password', 'https://example.com', 'https://example.com'); | ||
let promise = sdk.auth.login('email@example.com', 'password'); | ||
@@ -10,0 +10,0 @@ promise.then(function (response) { |
@@ -7,3 +7,3 @@ let sdk = new Appwrite(); | ||
let promise = sdk.projects.createTask('[PROJECT_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com'); | ||
let promise = sdk.projects.createTask('[PROJECT_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); | ||
@@ -10,0 +10,0 @@ promise.then(function (response) { |
@@ -7,3 +7,3 @@ let sdk = new Appwrite(); | ||
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com'); | ||
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); | ||
@@ -10,0 +10,0 @@ promise.then(function (response) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"license": "BSD-3-Clause", | ||
@@ -8,0 +8,0 @@ "main": "src/sdk.js", |
@@ -1,2 +0,2 @@ | ||
# Appwrite SDK for Javascript | ||
# Appwrite SDK for JavaScript | ||
@@ -10,4 +10,2 @@ ![License](https://img.shields.io/github/license/appwrite/sdk-for-js.svg?v=1) | ||
![Appwrite](https://appwrite.io/images/github.png) | ||
@@ -17,2 +15,4 @@ | ||
### NPM | ||
To install via [NPM](https://www.npmjs.com/): | ||
@@ -24,10 +24,35 @@ | ||
Install with CDN: | ||
If you're using a bundler (like [Browserify](http://browserify.org/) or [webpack](https://webpack.js.org/)), you can import the Appwrite module when you need it: | ||
```js | ||
import * as Appwrite from "appwrite"; | ||
``` | ||
### CDN | ||
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.0.23"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/appwrite@1.0.24"></script> | ||
``` | ||
## Getting Started | ||
Initialise the Appwrite SDK in your code, and setup your API credentials: | ||
```js | ||
// Init your JS SDK | ||
var appwrite = new Appwrite(); | ||
appwrite | ||
.setEndpoint('http://localhost/v1') // Set only when using self-hosted solution | ||
.setProject('455x34dfkj') // Your Appwrite Project UID | ||
; | ||
``` | ||
## License | ||
Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. |
(function(window){'use strict';window.Appwrite=function(){let config={endpoint:'https://appwrite.io/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index<params[p].length;index++){let param=params[p][index];str.push(encodeURIComponent(p+'[]')+"="+encodeURIComponent(param))}}else{str.push(encodeURIComponent(p)+"="+encodeURIComponent(params[p]))}} | ||
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:1.0.23');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')} | ||
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:1.0.24');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')} | ||
if(typeof path!=='string'){throw new Error('var path must be of type string')} | ||
@@ -26,6 +26,4 @@ if(typeof headers!=='object'){throw new Error('var headers must be of type object')} | ||
let path='/account/prefs';let payload={};if(prefs){payload.prefs=prefs} | ||
return http.patch(path,{'content-type':'application/json'},payload)},getSecurity:function(){let path='/account/security';let payload={};return http.get(path,{'content-type':'application/json'},payload)},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json'},payload)}};let auth={login:function(email,password,success,failure){if(email===undefined){throw new Error('Missing required parameter: "email"')} | ||
return http.patch(path,{'content-type':'application/json'},payload)},getSecurity:function(){let path='/account/security';let payload={};return http.get(path,{'content-type':'application/json'},payload)},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json'},payload)}};let auth={login:function(email,password,success='',failure=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} | ||
if(password===undefined){throw new Error('Missing required parameter: "password"')} | ||
if(success===undefined){throw new Error('Missing required parameter: "success"')} | ||
if(failure===undefined){throw new Error('Missing required parameter: "failure"')} | ||
let path='/auth/login';let payload={};if(email){payload.email=email} | ||
@@ -39,3 +37,3 @@ if(password){payload.password=password} | ||
if(failure){payload.failure=failure} | ||
return http.get(path,{'content-type':'application/json'},payload)},recovery:function(email,reset){if(email===undefined){throw new Error('Missing required parameter: "email"')} | ||
payload.project=config.project;return iframe('get',path,payload)},recovery:function(email,reset){if(email===undefined){throw new Error('Missing required parameter: "email"')} | ||
if(reset===undefined){throw new Error('Missing required parameter: "reset"')} | ||
@@ -42,0 +40,0 @@ let path='/auth/recovery';let payload={};if(email){payload.email=email} |
Sorry, the diff of this file is too big to display
55
193618
3377