import express from 'express';
// Initialise DB connection
const pgConnectionConfigs = {
user: '<MY_UNIX_USERNAME>',
database: '<MY_UNIX_USERNAME>',
port: 5432, // Postgres server always runs on this port by default
const pool = new Pool(pgConnectionConfigs);
app.get('/', (request, response) => {
console.log('request came in');
const whenDoneWithQuery = (error, result) => {
console.log('Error executing query', error.stack);
response.status(503).send(result.rows);
console.log(result.rows[0].name);
response.send(result.rows);
// Query using pg.Pool instead of pg.Client
pool.query('SELECT * from cats', whenDoneWithQuery);