Browse Source

Created skeleton for server

master
Jeffery R 6 years ago
parent
commit
47c92234fe
5 changed files with 67 additions and 1 deletions
  1. +7
    -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

+ 7
- 1
README.md View File

@ -1 +1,7 @@
GoogleTrendsGame
#GoogleTrendsGame
## Server dependencies
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