File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
var knex = require ( "knex" ) ( {
4
4
client : "pg" ,
5
- connection : process . env . DATABASE_URL || "postgres://ebaujsbvecjlzi:12edc63ce7e4c9ec49b6b97c6321fb42c0c1f2651f364bf61cbfad275222799b@ec2-23-21-171-25.compute-1.amazonaws.com:5432/dutnhmhd1tnph" ,
5
+ connection : process . env . DATABASE_URL ,
6
6
} ) ;
7
7
8
8
knex . schema . hasTable ( "accounts" ) . then ( function ( exists ) {
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const Hapi=require('hapi');
4
4
5
5
const port = + process . env . PORT || 5000 ;
6
6
const host = "0.0.0.0" ;
7
+ const knex = require ( knex ) ;
7
8
8
9
// Create a server with a host and port
9
10
const server = Hapi . server ( {
@@ -27,6 +28,21 @@ const start = async function() {
27
28
}
28
29
} ) ;
29
30
31
+ // Add the accounts getter
32
+ server . route ( {
33
+ method :'GET' ,
34
+ path :'/accounts' ,
35
+ handler : ( request , h ) => {
36
+ var pg = knex ( {
37
+ client : "pg" ,
38
+ connection : process . env . DATABASE_URL ,
39
+ } ) ;
40
+ return pg ( "accounts" ) . then ( results => {
41
+ return results ;
42
+ } ) ;
43
+ }
44
+ } ) ;
45
+
30
46
// Add the favicon route
31
47
server . route ( {
32
48
method :'GET' ,
You can’t perform that action at this time.
0 commit comments