-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
69 lines (58 loc) · 2.09 KB
/
app.js
File metadata and controls
69 lines (58 loc) · 2.09 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
57
58
59
60
61
62
63
64
65
66
67
68
69
// This is the main file of our chat app. It initializes a new
// express.js instance, requires the config and routes files
// and listens on a port. Start the application by running
// 'node app.js' in your terminal
var pg = require('pg');
var express = require('express'),
app = express();
// This is needed if the app is run on heroku:
var port = process.env.PORT || 8080;
// Initialize a new socket.io object. It is bound to
// the express app, which allows them to coexist.
var io = require('socket.io').listen(app.listen(port));
// Require the configuration and the routes files, and pass
// the app and io as arguments to the returned functions.
require('./config')(app, io);
require('./routes')(app, io);
var pg = require('pg');
/*var conString = "postgres://otadthilhxfiqv:sVgqucfFBBijtv9fFKaEAGnAIa@ec2-54-163-238-96.compute-1.amazonaws.com:5432/d59eb19fu1hs81";
var dataclinet = new pg.Client(conString);
dataclinet.connect();
var query = dataclinet.query("select * from employee");
// query.on("row", function (row, result) {
// result.addRow(row);
//});
*/
var dataclinet = new pg.Client({
user: "otadthilhxfiqv",
password: "sVgqucfFBBijtv9fFKaEAGnAIa",
database: "d59eb19fu1hs81",
port: 5432,
host: "ec2-54-163-238-96.compute-1.amazonaws.com",
ssl: true
});
/*
var dataclinet = new pg.Client({
user: "post",
password: "post",
database: "postgres",
port: 5432,
host: "localhost",
ssl: false
});
*/
dataclinet.connect();
var query = dataclinet.query("select * from test;");
query.on("row", function (row, result) {
result.addRow(row);
});
query.on("end", function (result) {
dataclinet.end();
//res.writeHead(200, {'Content-Type': 'text/plain'});
//res.write(JSON.stringify(result.rows, null, " ") + "\n");
//res.end();
console.log(result.rows);
});
console.log('modified');
console.log('Your application is running on http://localhost:' + port);
console.log('Your application is running on http://localhost:' + port);