diff --git a/README.md b/README.md index 2d9382d..aca344e 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -GoogleTrendsGame +#GoogleTrendsGame + + +## Server dependencies +npm install mysql +npm install sanitizer +npm install google-trends-api \ No newline at end of file diff --git a/googletrendsgame/server/server.js b/googletrendsgame/server/server.js new file mode 100644 index 0000000..4143a13 --- /dev/null +++ b/googletrendsgame/server/server.js @@ -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'); +}); \ No newline at end of file diff --git a/googletrendsgame/server/sql.js b/googletrendsgame/server/sql.js new file mode 100644 index 0000000..2797956 --- /dev/null +++ b/googletrendsgame/server/sql.js @@ -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); + }); + }) + } + }; \ No newline at end of file diff --git a/googletrendsgame/server/trendsAPI.js b/googletrendsgame/server/trendsAPI.js new file mode 100644 index 0000000..c3abe26 --- /dev/null +++ b/googletrendsgame/server/trendsAPI.js @@ -0,0 +1,9 @@ + + +module.exports= + { + getPopularity: function(word) + { + return 0; + } + }; \ No newline at end of file diff --git a/googletrendsgame/server/utils.js b/googletrendsgame/server/utils.js new file mode 100644 index 0000000..e69de29