
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@oly_op/pg-helpers
Advanced tools
pg-helpers is a wrapper library for the popular node-postgres library (pg
npm package). It adds many utilities including a query
function that makes inserting variables and parameters a lot easier in my opinion. It does this by using a simple template mechanism in your SQL code that allows you to insert a variable or a parameter.
$ npm install @oly_op/pg-helpers
@oly_op/pg-helpers
re-exports everything from pg
.
import type { Pool, PoolClient, QueryResult as ResultBase } from "pg";
export type PoolOrClient = Pool | PoolClient;
export type Row = Record<string, unknown>;
export type Result<T = Row> = ResultBase<T>;
query
// definition
query(client: PoolOrClient) =>
(sql: string) =>
<T>(input?: QueryOptions<T> | undefined) =>
Promise<T>;
// types
export type VariableType = string | number | boolean | null
export interface Variable {
key: string,
value: VariableType,
parameterized?: boolean,
}
export type VariableInput = Variable[] | Record<string, VariableType>
export type Parse<T> = (result: Result) => T
export interface QueryOptionsLog {
sql?: boolean,
result?: boolean,
variables?: boolean,
}
export interface QueryOptions<T> {
parse?: Parse<T>,
log?: QueryOptionsLog,
variables?: VariableInput,
}
// example #1
interface User {
name: string,
userID: string,
}
const getUser =
async (userID: string) =>
query(context.pg)(`
SELECT
{{ columnNames }}
FROM
users
WHERE
user_id = '{{ userID }}'
`)({
parse: convertFirstRowToCamelCase<User>(),
variables: {
userID,
columnNames: join(["user_id", "name"]),
},
})
console.log((await getUser("1234")).name)
FAQs
pg-helpers
We found that @oly_op/pg-helpers 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.