-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (31 loc) · 1.16 KB
/
server.js
File metadata and controls
42 lines (31 loc) · 1.16 KB
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
let mysql = require('mysql');
let config = require('./config.js');
const fetch = require('node-fetch');
const express = require("express");
const path = require("path");
const bodyParser = require("body-parser");
const { response } = require('express');
const app = express();
const port = process.env.PORT || 5000;
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.use(express.static(path.join(__dirname, "client/build")));
app.post('/api/loadUserSettings', (req, res) => {
let connection = mysql.createConnection(config);
let userID = req.body.userID;
let sql = `SELECT mode FROM user WHERE userID = ?`;
console.log(sql);
let data = [userID];
console.log(data);
connection.query(sql, data, (error, results, fields) => {
if (error) {
return console.error(error.message);
}
let string = JSON.stringify(results);
//let obj = JSON.parse(string);
res.send({ express: string });
});
connection.end();
});
app.listen(port, () => console.log(`Listening on port ${port}`)); //for the dev version
//app.listen(port, '129.97.25.211'); //for the deployed version, specify the IP address of the server