-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
48 lines (42 loc) · 1.21 KB
/
server.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
const express = require('express');
const app = express();
const port = process.env.PORT || 5000;
// console.log that your server is up and running
app.listen(port, () => console.log(`Listening on port ${port}`));
// create a GET route
app.get('/signin', (req, res) => {
const email = req.query.email;
const password = req.query.password;
//Check database to see if it's valid user
const validUser = (email == "[email protected]" && password == "123");
if(validUser) {
res.send({
isLoggedIn: true,
logMessage: 'Welcome to Sharenote!'
});
} else {
res.send({
isLoggedIn: false,
logMessage: 'Username and password doesn\'t match.'
});
}
});
app.get('/signup', (req, res) => {
const email = req.query.email;
const password = req.query.password;
// Check database to see if email is registed already
// If not send back a successful message
// Otherwise send back alert message
const accountExist = (email == "[email protected]");
if(accountExist) {
res.send({
isRegistered: true,
message: 'The email address is registed already!'
});
} else {
res.send({
isRegistered: false,
message: 'Thanks for register Sharenote!'
});
}
});