-
Notifications
You must be signed in to change notification settings - Fork 0
/
fire.js
38 lines (32 loc) · 997 Bytes
/
fire.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
const firebase = require("firebase");
var config = {
apiKey: "AIzaSyB9TmL9Aflud92q8D7mh82YuzvilC2Ekyo",
authDomain: "netforce-81489.firebaseapp.com",
databaseURL: "https://netforce-81489.firebaseio.com",
storageBucket: "netforce-81489.appspot.com",
messagingSenderId: "42658269280"
};
firebase.initializeApp(config);
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
module.exports.firebase = firebase.database();
module.exports.write=function(model,vals,cb){
firebase.database().ref(model).push().set(vals).then(cb);
}
module.exports.writeUserData = function (userId, name, email, imageUrl,cb) {
firebase.database().ref('users/' + userId).set({
username: name,
email: email,
profile_picture : imageUrl
}).then(cb);
}
module.exports.fetchData=function(func){
return func
}