-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.js
More file actions
35 lines (24 loc) · 787 Bytes
/
routes.js
File metadata and controls
35 lines (24 loc) · 787 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
// This file is required by the app
// It sets up event listeners
// For the different URL endpoints of the application
module.exports = function(app, io, db) {
app.get('/', function (req, res) {
res.render('login');
});
app.get('/game', function (req, res) {
res.render('main');
});
app.post('/adduser', function (req, res) {
var playerName = req.body.playerName;
var searchQuery = {};
searchQuery["playerName"] = playerName;
collection = db.collection('war');
collection.find(searchQuery).toArray(function(err, docs) {
if(docs.length != 0) {
alert("Name is already taken!");
} else {
res.redirect('game');
}
});
});
};