-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
56 lines (45 loc) · 1.17 KB
/
server.js
File metadata and controls
56 lines (45 loc) · 1.17 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const express = require('express');
var path = require("path");
const app = express()
const port = 4444
app.use(express.static('front-end/dist'))
app.use(express.json());
const { Pool } = require('pg');
const pool = new Pool({
user: 'postgres',
host: 'postgres',
database: 'ctagdb',
password: 'postgres',
port: 5432,
});
pool.connect((err, client, release) => {
if (err) {
return console.error('Error acquiring client', err.stack)
}
client.query('SELECT NOW()', (err, result) => {
release()
if (err) {
return console.error('Error executing query', err.stack)
}
console.log(result.rows)
})
});
app.get('/', (req, res) => {
res.status(200).send("Server up and running!");
});
// Get User Data
app.get('/profile/:userhash', (req, res) => {
userhash = req.params.userhash;
console.log(userhash);
pool.query(`SELECT * FROM ctag_profile WHERE hashpoint='${userhash}'`)
.then((data) => {
res.status(200).send(data);
})
.catch((err) => {
res.status(500).send(err);
});
})
app.post('/profile', (req, res) => {
});
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
module.exports = app;