-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
676 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,53 @@ | ||
## Setup | ||
|
||
1. [Install React-Native](https://facebook.github.io/react-native/docs/getting-started.html#content) | ||
1. ```git clone https://github.com/bartonhammond/snowflake.git``` | ||
1. cd snowflake | ||
1. npm install | ||
1. Copy or move ```src/lib/config.example.js``` to ```src/lib/config.js```. | ||
1. Create account and app on Parse.com | ||
1. Copy the Parse.com app keys for APP_ID and REST_API_KEY and update ```src/lib/config.js``` | ||
1. Update the Apps Settings -> Authentication | ||
1. Allow username and password-based authentication -> Yes | ||
1. Allow anonymous users -> No | ||
1. Update the Apps Settings -> Email | ||
1. Verify user emails -> Yes | ||
1. On mac, open XCode and load project | ||
1. For android, ```react-native run-android``` assuming you have an emulator or device attached. | ||
1. To run Jest, ```npm test``` | ||
1. To debug Jest unit cases, install [node_inspector](https://github.com/node-inspector/node-inspector) and run ```npm run test-chrome``` | ||
1. Enjoy! | ||
* [Install React-Native](https://facebook.github.io/react-native/docs/getting-started.html#content) | ||
|
||
* Clone snowflake: | ||
|
||
``` | ||
git clone https://github.com/bartonhammond/snowflake.git | ||
``` | ||
|
||
* cd snowflake | ||
``` | ||
npm install | ||
``` | ||
|
||
* Copy or move ```src/lib/config.example.js``` to ```src/lib/config.js```. | ||
* Note: you must select one of three options for the ```backend``` as shown below: | ||
|
||
``` | ||
backend: { | ||
parse: false, | ||
hapiLocal: false, | ||
hapiRemote: true | ||
}, | ||
``` | ||
* To run Hapi either locally on remotely on OpenShift, update the below ```src/lib/config.js``` file: | ||
|
||
``` | ||
HAPI: { | ||
local: { | ||
url: 'http://127.0.0.1:5000' | ||
}, | ||
remote: { | ||
url: 'https://mysnowflake-bartonhammond.rhcloud.com' | ||
} | ||
} | ||
``` | ||
|
||
* If you choose Parse.com, create account and app on Parse.com | ||
* Copy the Parse.com app keys for APP_ID and REST_API_KEY and update ```src/lib/config.js``` | ||
* Update the Apps Settings -> Authentication | ||
* Allow username and password-based authentication -> Yes | ||
* Allow anonymous users -> No | ||
* Update the Apps Settings -> Email | ||
* Verify user emails -> Yes | ||
|
||
### To run: | ||
* On mac, open XCode and load project | ||
* For android, ```react-native run-android``` assuming you have an emulator or device attached. | ||
* To run Jest, ```npm test``` | ||
* To debug Jest unit cases, install [node_inspector](https://github.com/node-inspector/node-inspector) and run ```npm run test-chrome``` | ||
* Enjoy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/** | ||
* # Backend.js | ||
* | ||
* Abstract Base class for Backend support | ||
* | ||
*/ | ||
'use string'; | ||
/** | ||
* ## Async support | ||
* | ||
*/ | ||
require('regenerator/runtime'); | ||
|
||
/** | ||
* ## Imports | ||
* | ||
* Config for defaults and underscore for a couple of features | ||
*/ | ||
import CONFIG from './config'; | ||
import _ from 'underscore'; | ||
|
||
export default class Backend { | ||
/** | ||
* ## Constructor | ||
* | ||
* | ||
* @throws tokenMissing if token is undefined | ||
*/ | ||
constructor( token) { | ||
} | ||
/** | ||
* ### signup | ||
* | ||
* @param data object | ||
* | ||
* {username: "barton", email: "[email protected]", password: "Passw0rd!"} | ||
* | ||
* @return | ||
* if ok, {createdAt: "2015-12-30T15:17:05.379Z", | ||
* objectId: "5TgExo2wBA", | ||
* sessionToken: "r:dEgdUkcs2ydMV9Y9mt8HcBrDM"} | ||
* | ||
* if error, {code: xxx, error: 'message'} | ||
*/ | ||
async signup(data) { | ||
|
||
} | ||
/** | ||
* ### login | ||
* encode the data and and call _fetch | ||
* | ||
* @param data | ||
* | ||
* {username: "barton", password: "Passw0rd!"} | ||
* | ||
* @returns | ||
* | ||
* createdAt: "2015-12-30T15:29:36.611Z" | ||
* email: "[email protected]" | ||
* objectId: "Z4yvP19OeL" | ||
* sessionToken: "r:Kt9wXIBWD0dNijNIq2u5rRllW" | ||
* updatedAt: "2015-12-30T16:08:50.419Z" | ||
* username: "barton" | ||
* | ||
*/ | ||
async login(data) { | ||
|
||
} | ||
/** | ||
* ### logout | ||
* prepare the request and call _fetch | ||
*/ | ||
async logout() { | ||
|
||
} | ||
/** | ||
* ### resetPassword | ||
* the data is already in a JSON format, so call _fetch | ||
* | ||
* @param data | ||
* {email: "[email protected]"} | ||
* | ||
* @returns empty object | ||
* | ||
* if error: {code: xxx, error: 'message'} | ||
*/ | ||
async resetPassword(data) { | ||
|
||
} | ||
/** | ||
* ### getProfile | ||
* Using the sessionToken, we'll get everything about | ||
* the current user. | ||
* | ||
* @returns | ||
* | ||
* if good: | ||
* {createdAt: "2015-12-30T15:29:36.611Z" | ||
* email: "[email protected]" | ||
* objectId: "Z4yvP19OeL" | ||
* sessionToken: "r:uFeYONgIsZMPyxOWVJ6VqJGqv" | ||
* updatedAt: "2015-12-30T15:29:36.611Z" | ||
* username: "barton"} | ||
* | ||
* if error, {code: xxx, error: 'message'} | ||
*/ | ||
async getProfile() { | ||
} | ||
/** | ||
* ### updateProfile | ||
* for this user, update their record | ||
* the data is already in JSON format | ||
* | ||
* @param userId _id of Parse.com | ||
* @param data object: | ||
* {username: "barton", email: "[email protected]"} | ||
*/ | ||
async updateProfile(userId,data) { | ||
} | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* # Parse.js | ||
* | ||
* This class interfaces with Parse.com using the rest api | ||
* see [https://parse.com/docs/rest/guide](https://parse.com/docs/rest/guide) | ||
* | ||
*/ | ||
'use string'; | ||
|
||
import CONFIG from './config'; | ||
import Parse from './Parse'; | ||
import Hapi from './Hapi'; | ||
|
||
export default function BackendFactory(token = null) { | ||
if (CONFIG.backend.parse) { | ||
return new Parse(token); | ||
} else if (CONFIG.backend.hapiLocal || CONFIG.backend.hapiRemote) { | ||
return new Hapi(token); | ||
|
||
} | ||
} |
Oops, something went wrong.