Browse Source

Merge remote-tracking branch 'origin/master'

master
Unknown 7 years ago
parent
commit
3692c7a3d3
5 changed files with 75 additions and 1 deletions
  1. +15
    -1
      README.md
  2. +19
    -0
      googletrendsgame/server/server.js
  3. +32
    -0
      googletrendsgame/server/sql.js
  4. +9
    -0
      googletrendsgame/server/trendsAPI.js
  5. +0
    -0
      googletrendsgame/server/utils.js

+ 15
- 1
README.md View File

@ -1 +1,15 @@
GoogleTrendsGame
# GoogleTrendsGame
Guess the trends beat your friends
## Server dependencies
````
npm init
npm install express
npm install socket.io
npm install mysql
npm install sanitizer
npm install google-trends-api
````

+ 19
- 0
googletrendsgame/server/server.js View File

@ -0,0 +1,19 @@
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
const port = 3000;
//Whenever someone connects this gets executed
io.on('connection', function(socket) {
console.log('A user connected');
//Whenever someone disconnects this piece of code executed
socket.on('disconnect', function () {
console.log('A user disconnected');
});
});
http.listen(port, function() {
console.log('listening on *:3000');
});

+ 32
- 0
googletrendsgame/server/sql.js View File

@ -0,0 +1,32 @@
//
const mysql = require('mysql');
const sanitizer = require('sanitizer');
module.exports=
{
/**
* Function used to use insert statements into the database
*
* Don't worry, the input gets sanitized
*
* @param sqlStatement
* @return the id of the new record - if there is one
*/
insert : function(sqlStatement)
{
return new Promise(function(resolve, reject)
{
con.query(sanitizer.sanitize(sqlStatement), function (err, result)
{
if (err)
{
console.log(err);
resolve(0);
}
resolve(result.insertId);
});
})
}
};

+ 9
- 0
googletrendsgame/server/trendsAPI.js View File

@ -0,0 +1,9 @@
module.exports=
{
getPopularity: function(word)
{
return 0;
}
};

+ 0
- 0
googletrendsgame/server/utils.js View File


Loading…
Cancel
Save