-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (41 loc) · 1012 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
40
41
42
43
44
45
46
47
48
49
50
51
52
const express = require('express')
const app = express()
require('dotenv').config()
const { loginUser, registerUser, verifyUser } = require('./cognito')
app.listen(3000, () => {
console.log(`app listening at http://localhost:3000`)
})
app.post('/login', async (req, res) => {
const { email, password } = req.query
try {
const response = await loginUser({
email: email,
password: password,
})
res.json(response)
} catch (err) {
res.json({ error: err })
}
})
app.post('/register', async (req, res) => {
const { email, username, password } = req.query
try {
const response = await registerUser({
email: email,
username: username,
password: password,
})
res.json(response)
} catch (err) {
res.json({ error: err })
}
})
app.post('/verify', async (req, res) => {
const { token } = req.query
try {
const response = await verifyUser({ token })
res.json(response)
} catch (err) {
res.json({ error: err })
}
})