Package Exports
- psql-web-app
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (psql-web-app) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
A PSQL webapp
This is an Express app that will allow implement a PSQL like query tool in your browser.
It looks like this:
Install
Just:
npm install psql-web-app
How to use it
In your Express app, you need something like:
const express = require("express");
const psqlWebApp = require("psql-web-app");
const { Pool } = require('pg');
const pool = new Pool(databaseConfig); // your own db connection details
const app = express();
app.query = function (sql, parameters) {
let client = await pool.connect();
let result = await client.query(sql, parameters);
return result;
};
psqlWebApp.init(app);
in other words you need to implement a query
function which will
return a result-set; the function needs to be added to the app
object which psqlWebApp.init
receives.
See here for details
on the databaseConfig
for the pg
library.
Options
You can also pass in a middleware function to be added to all the routes handlers for the PSQL web app so that you can use authentication or such like.
Like so:
psqlWebApp.init(app, {
middleware: function (request, response, next) {
console.log("logging path middleware", request.path);
next();
}
});
The middleware functions must be valid Express middleware.
If you want a list of middleware you'll need to implement that yourself, within a single middleware.