
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
PostgresSQL client to Nodejs servers
Did you like the project? Please, considerate a donation to help improve!
PostgresSQL client to Nodejs servers✨
Connect your database easily using the pgnode package
To install the module in your project just run the command below:
npm i pgnode
or
yarn add pgnode
Now in your project just import the module like this:
const pg = require("pgnode");
Or you can use import:
import pg from "pgnode";
This is the simplest possible way to connect, query, and disconnect with async/await:
import pg, { Client, Pool } from "pgnode";
const config = {
user: process.env.POSTGRES_USER,
host: process.env.POSTGRES_HOST,
database: process.env.POSTGRES_DATABASE,
password: process.env.POSTGRES_PASSWORD,
port: Number(process.env.POSTGRES_PORT),
};
const client = new pg.Client({ ...config });
function query(sql, params) {
return client
.connect()
.then(() => client.query(sql, params))
.then((res) => {
client.end();
return res;
});
}
import {tx, Client, Pool} from 'pgnode';
const client = new Client({
user: process.env.POSTGRES_USER,
host: process.env.POSTGRES_HOST,
database: process.env.POSTGRES_DATABASE,
password: process.env.POSTGRES_PASSWORD,
port: Number(process.env.POSTGRES_PORT)
});
const pool = new Pool({...client});
export async function createTable(){
return await tx(pool, async (db) => {
await db.query(`
CREATE TABLE IF NOT EXISTS test
(
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);`);
});
}
// or use a generator function to create the transactions
export function* createTableGenerator(){
yield tx(pool, async (db) => {
await db.query(`
CREATE TABLE IF NOT EXISTS test
(
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);`);
});
// create another transaction
yield tx(pool, async (db) => {
await db.query(`
INSERT INTO test (name) VALUES ('test');`);
});
}
tls.connect
options being passed to the client/pool constructor under the ssl
option.LISTEN/NOTIFY
COPY TO/COPY FROM
pg.Client
and pg.Pool
are ES6 classespg.Client.prototype.query
and pg.Pool.prototype.query
^v16x
FAQs
PostgresSQL client to Nodejs servers
The npm package pgnode receives a total of 4 weekly downloads. As such, pgnode popularity was classified as not popular.
We found that pgnode demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.