Skip to content

Commit

Permalink
[RELEASE] Version v0.0.5. Merged to get correctly working isInGroup a…
Browse files Browse the repository at this point in the history
…nd isInGroups methods.
  • Loading branch information
Scott Prue committed Sep 3, 2015
2 parents 3b9e47a + 4760479 commit 05ba69e
Show file tree
Hide file tree
Showing 15 changed files with 323 additions and 253 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ tmp

.DS_Store
**/.DS_Store
wiki
wiki/**
202 changes: 42 additions & 160 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
# Matter

[![Travis build status](https://travis-ci.org/KyperTech/matter.svg?branch=master)](https://travis-ci.org/kypertech/matter)
[![Code Climate](https://codeclimate.com/github/KyperTech/matter/badges/gpa.svg)](https://codeclimate.com/github/kypertech/matter)
[![Test Coverage](https://codeclimate.com/github/KyperTech/matter/badges/coverage.svg)](https://codeclimate.com/github/KyperTech/matter)
[![Dependency Status](https://david-dm.org/kypertech/matter.svg)](https://david-dm.org/kypertech/matter)
[![devDependency Status](https://david-dm.org/kypertech/matter/dev-status.svg)](https://david-dm.org/kypertech/matter#info=devDependencies)

Isomorphic javascript library that provides common web application functionality such as user authentication and local/session/token storage. Matter communicates with [Tessellate](https://github.com/KyperTech/tessellate) for application data.

## Getting Started
<p align="center">
<!-- Npm Version -->
<a href="https://npmjs.org/package/kyper-matter">
<img src="https://img.shields.io/npm/v/kyper-matter.svg" alt="npm version">
</a>
<!-- Build Status -->
<a href="https://travis-ci.org/KyperTech/matter">
<img src="http://img.shields.io/travis/KyperTech/matter.svg" alt="build status">
</a>
<!-- Dependency Status -->
<a href="https://david-dm.org/KyperTech/matter">
<img src="https://david-dm.org/KyperTech/matter.svg" alt="dependency status">
</a>
<!-- Codeclimate -->
<a href="https://codeclimate.com/github/kypertech/matter">
<img src="https://codeclimate.com/github/KyperTech/matter/badges/gpa.svg" alt="codeclimate">
</a>
<!-- Coverage -->
<a href="https://codeclimate.com/github/KyperTech/matter">
<img src="https://codeclimate.com/github/KyperTech/matter/badges/coverage.svg" alt="coverage">
</a>
<!-- License -->
<a href="https://github.com/KyperTech/matter/blob/master/LICENSE.md">
<img src="https://img.shields.io/npm/l/kyper-matter.svg" alt="license">
</a>
</p>
> *What are the minimal tools I need to make an app* **matter***?*
Matter is a Javascript library that provides common web application functionality such as user authentication and local/session/token storage. This library communicates with [Tessellate](https://github.com/KyperTech/tessellate) for application data, but custom server setups are on the roadmap.

Matter is Isomorphic, which means it will work well in both Browser and NodeJS environments. ES6 functionality is also available through importing and/or extending Matter (more details below).

## Quick Start

Using Matter requires having created an application on [Tessellate](http://tessellate.elasticbeanstalk.com) or [running your own Tessellate server]().

Expand All @@ -19,7 +42,8 @@ Using Matter requires having created an application on [Tessellate](http://tesse

To use the CDN, add the following script tag to your `index.html`:

```html
```HTML
<!-- Matter Library Bundle -->
<script src="http://cdn.kyper.io/js/matter/0.0.4/matter.bundle.js"></script>
```
#### Bower
Expand All @@ -28,8 +52,9 @@ Using Matter requires having created an application on [Tessellate](http://tesse
1. Start using Matter by providing the name of the app you created on [Tessellate](http://tessellate.elasticbeanstalk.com).

```javascript
//New matter object with the application name 'exampleApp'
//New Matter object with the application name 'exampleApp'
var matter = new Matter('exampleApp');

//Login to account with username "test" and password "test"
matter.login({username:"test", password:"test"}).then(function(user){
console.log('User logged into exampleApp:', user);
Expand All @@ -47,160 +72,17 @@ matter.login({username:"test", password:"test"}).then(function(user){
console.log('User logged into exampleApp:', user);
});
```
## Docs

## API Documentation

### Methods
Methods are part of the matter object you create in the getting started guide:

```javascript
var matter = new Matter('exampleApp');
```
### Authentication

#### `login()`

Log user in provided username/email and password.

**Example:**
```javascript
matter.login({username: 'test', password: 'test'})
.then(function(userData){ console.log('User logged in', userData)});
```

#### `signup()`

Create a new user and login

**Example:**
```javascript
Matter.signup({username: 'test', name:'Test User', password: 'test'})
.then(function(userData){ console.log('User signed up.', userData)});
```
#### `logout()`

Log current user out.

**Example:**
```javascript
Matter.logout().then(function(){
console.log('User logged out');
});
```

#### `isLoggedIn`

Get whether or not there is a user currently logged in

**Example:**
```javascript
if(matter.isLoggedIn){
console.log('User is currently logged in.');
}
```

#### `currentUser`

Get current user data if it is available. Returns `null` if no user is currently logged in.

**Example:**
```javascript
if(matter.currentUser){
console.log('The current users data:', matter.currentUser);
}
if(matter.currentUser == null){
console.log('No user is currently logged in.');
}
```

#### `getCurrentUser()`

Get currently logged in user.

**Example:**
```javascript
Matter.currentUser().then(function(user){ console.log('Currently logged in user:', user)});
```


### token
Get Auth token for currently logged in user

**Example:**
```javascript
//Get token as a string
var token = matter.token.string;

//Get Decoded token data
var tokenData = matter.token.data;

```

### storage

Internal storage that safley uses session storage when available.

#### `storage.setItem()`

Safley store item within in memory storage and session storage when available (in the browser). Works for strings and objects.

Alias: `storage.item`

**Example:**

```javascript
//Storing a string
storage.setItem('myString', 'AnyStringValue');

//Storing an object
var myData = {some:'example data'};
storage.setItem('myObject', myData);

//Using item alias
storage.item('myString', 'AnyStringValue');

```

#### `storage.getItem()`

Safley get an item within in memory storage and session storage when available (in the browser). Works for strings and objects.

**Example:**

```javascript
//Getting a string
var myStr = storage.getItem('myString');

//Getting an object
var myObj = storage.getItem('myObject');
```

### Settings
Pass a settings object when creating a new Matter object:

```javascript
//Reference another tessellate server
var matter = new Matter('exampleApp', {serverUrl:'https://test.elasticbeanstalk.com'});

//Set api server to local (for local tessellate instance)
var localMatter = new Matter('exampleApp', {localServer:true});

```
#### serverUrl
**type**: `string`

Set server url. If you are using a separately hosted Tessellate server or a server of your own, this is where you will set your server's base url.

#### localServer
**type**: `Boolean`
### [API Documentation](https://github.com/KyperTech/matter/wiki/API-Documentation)

Use local server url instead of hosted version of [Tessellate](http://tessellate.elasticbeanstalk.com)
### [Examples](https://github.com/KyperTech/matter/tree/master/examples)

## More Information
For more details please visit the [Matter Wiki](https://github.com/KyperTech/matter/wiki).

## TODO
* 3rd Party provider logins (keys set on tessellate)
* Session publicly accessible
* Update user info Method
* Improve Documentation
* Run tests git pre-push
* More local storage capabilities
Expand Down

0 comments on commit 05ba69e

Please sign in to comment.