-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (31 loc) · 851 Bytes
/
server.js
File metadata and controls
36 lines (31 loc) · 851 Bytes
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
const express = require("express");
const firebase = require("firebase");
const app = express();
const port = 3000;
class Server {
constructor() {
this.init();
this.start();
}
init() {
var config = {
apiKey: 'AIzaSyAYBgORfDq6ptpb9k6jE3N5UHonW75EYPE',
authDomain: 'stevenfitzpatrick-5181b.firebaseapp.com',
databaseURL: 'https://stevenfitzpatrick-5181b.firebaseio.com'
};
firebase.initializeApp(config);
debugger;
}
start() {
app.listen(port, err => {
console.log(`App running on port ${port}`);
});
app.get("/", (req, res) => {
//res.send("welcome to my api with nodemon !");
firebase.database().ref('favourites').on('value', (data) => {
res.send(data.val());
})
});
}
}
const server = new Server();