It sounds like you want to create a HTTP endpoint, is that correct?
For this, you will probably want to use express.js.
There are plenty of great tutorials out there on create a HTTP server with express, however this will get you started:
Install the express module via the node package manager.
From your terminal/command line, type:
cd project-name
npm install express --save
Modify your node server to the following:
var Massive = require("massive")
, http = require("http") // import http
, express = require("express") // import express
, app = express(); // instantiate your app
/* database config */
var connectionString = "postgres://postgres:postgres@localhost/postgres";
var db = Massive.connectSync({connectionString : connectionString});
/* http routes */
app.get("/",function(req,res){
// req is the request object
// res is the response object
db.query("Select * from company", function (err, data) {
// send a http response with status code 200 and the body as the query data.
res.status(200).send(data);
});
});
/* listen in port 3000 */
var server = http.createServer(app);
server.listen(3000);
This application will listen on port 3000, and respond to requests to '/', eg http://localhost:3000/. The database will be queried and the result will be send as the response to the HTTP request.