-
Notifications
You must be signed in to change notification settings - Fork 0
/
flamelink.js
84 lines (76 loc) · 2.23 KB
/
flamelink.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const config = {
apiKey: "AIzaSyAv9yGgMWcNDlX8loyOEta8GTS_wZGHkp4",
authDomain: "karachivynz-3f361.firebaseapp.com",
databaseURL: "https://karachivynz-3f361.firebaseio.com",
projectId: "karachivynz-3f361",
storageBucket: "karachivynz-3f361.appspot.com",
messagingSenderId: "142377060579"
};
/*const app = flamelink({
apiKey: "AIzaSyAv9yGgMWcNDlX8loyOEta8GTS_wZGHkp4",
authDomain: "karachivynz-3f361.firebaseapp.com",
databaseURL: "https://karachivynz-3f361.firebaseio.com",
projectId: "karachivynz-3f361",
storageBucket: "karachivynz-3f361.appspot.com",
messagingSenderId: "142377060579"
});*/
const firebaseApp = firebase.initializeApp(config);
const database = firebase.database();
var email = '[email protected]';
var password = 'superuser321';
var authService = firebase.auth().signInWithEmailAndPassword(email, password)
.then(function (success) {
console.log(success);
})
.catch(function (error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
const app = flamelink({ firebaseApp, authService });
app.content.get('newsAndUpdates')
.then(function (newsAndUpdates) {
console.log(newsAndUpdates);
callback(newsAndUpdates);
})
.catch(function (error) {
console.log(error);
});
function getData(callback) {
app.content.get('newsAndUpdates')
.then(function (newsAndUpdates) {
console.log(newsAndUpdates);
callback(newsAndUpdates);
})
.catch(function (error) {
console.log(error);
});
}
function createUser() {
const hash = md5(userCreateData.email);
app.content.set('user', hash, userCreateData)
.then(function () { console.log('Setting the entry succeeded') })
.catch(function (err) {
console.log(err);
console.error('Something went wrong while setting the entry.')
});
}
const userCreateData = {
firstName: 'dani',
lastName: 'usmani',
dateOfBirth: '17/07/1993',
createAt: Date.now(),
updatedAt: Date.now(),
facebook: {},
email: '[email protected]',
additionalDetail: 'Test Details',
gender: 'Male'
}
function writeYoutubeData() {
var id = "12345"
database.ref('youtube/'+ id).set({
title: 'Dummy Title',
token: 'acnasdljhasdflkhasdkfjasdf'
});
}