require('dotenv').config(); const express = require('express'); const server = express(); const pg = require('pg'); var Postgres = new pg.Client({ user: process.env.user, password: process.env.password, host: process.env.host, port: process.env.port, database: process.env.database, ssl: false, application_name: "osm_api" }); Postgres.connect(); Postgres.FirstRow = function(inSQL,args, inResponse) { Postgres.query(inSQL,args, (err, res) => { if (err === null) { inResponse.json(res.rows[0]); return; } inResponse.json(err.stack); }); }; server.get('/list_sources', function (req,res) { var sql = "select jsonb_agg(defn) from tps.srce"; console.log(req.query); Postgres.FirstRow(sql,[],res); }) server.get('/', (req,res) => res.send('its running yay 🎡')) server.listen(3000,() => console.log('started'))