-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (31 loc) · 1013 Bytes
/
index.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
const admin = require("./firebase-config")
const express = require("express")
const bodyParser = require('body-parser')
const cors = require('./middleware/cors')
const PORT = process.env.PORT || 8080
const app = express()
// create application/json parser
app.use(bodyParser.json())
// create application/x-www-form-urlencoded parser
app.use(bodyParser.urlencoded({ extended: true }))
app.use(cors)
app.post("/verify", (req, res) => {
const idToken = req.body.token
console.log('token: ', idToken)
// idToken comes from the client app
admin.auth().verifyIdToken(idToken)
.then(function(decodedToken) {
let uid = decodedToken.uid;
res.send({ uid })
// ...
}).catch(function(error) {
// Handle error
console.log(error)
res.send("Error!")
});
})
app.get('/test', (req, res) => {
console.log('test route hit')
res.send('Testing...')
})
app.listen(PORT, () => console.log('Running on ', PORT))