Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@neondatabase/serverless

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neondatabase/serverless - npm Package Compare versions

Comparing version 0.4.11 to 0.4.12

27

index.d.ts

@@ -109,2 +109,19 @@

type QueryRows<ArrayMode extends boolean> =
ArrayMode extends true ? any[][] :
Record<string, any>[];
interface BriefFieldDef {
name: string;
dataTypeID: number;
}
interface FullQueryResults<ArrayMode extends boolean> {
fields: BriefFieldDef[];
command: string;
rowCount: number;
rows: QueryRows<ArrayMode>;
rowAsArray?: ArrayMode;
}
/**

@@ -149,6 +166,12 @@ * This experimental function returns an async tagged-template function that

*/
export function neon(connectionString: string, options?: { arrayMode?: boolean, fullResults?: boolean }): (
export function neon<ArrayMode extends boolean = false, FullResults extends boolean = false>(
connectionString: string,
options?: {
arrayMode?: ArrayMode;
fullResults?: FullResults;
}
): (
strings: TemplateStringsArray | string,
...params: any[]
) => Promise<any[]>;
) => Promise<FullResults extends true ? FullQueryResults<ArrayMode> : QueryRows<ArrayMode>>;

2

package.json
{
"name": "@neondatabase/serverless",
"version": "0.4.11",
"version": "0.4.12",
"author": "Neon",

@@ -5,0 +5,0 @@ "description": "node-postgres for serverless environments from neon.tech",

# @neondatabase/serverless [BETA]
This package from [Neon](https://neon.tech) shims the [node-postgres](https://node-postgres.com/) `pg` library to work on serverless runtimes such as Cloudflare Workers and Vercel Edge Functions — places where TCP sockets are not available — via a WebSocket proxy.
This package from [Neon](https://neon.tech) shims the [node-postgres](https://node-postgres.com/) `pg` library to work on serverless runtimes such as Cloudflare Workers and Vercel Edge Functions — places where TCP sockets may not be not available — via WebSockets or https fetch.

@@ -32,3 +32,3 @@ The package also works in web browsers, but in most cases it's not appropriate to publicly deploy that way because it would reveal your Postgres credentials.

* **Pooling**: in general, serverless platforms don't keep WebSocket connections alive between requests. So it won't generally work to connect a database client (or establish a connection pool) outside of the function that's run on each request. You can of course use a `Pool` within your request handler as a slightly terser way to acquire and connect a `Client`.
* **Pooling**: in general, serverless platforms don't keep WebSocket connections alive between requests. So it won't generally work to connect a database client (or establish a connection pool) outside of the function that's run on each request. You can of course use a `Pool` within your request handler as a slightly terser way to acquire and connect one or more `Client` objects, as shown above.

@@ -45,3 +45,3 @@ * **Cloudflare**: brief queries such as the one shown above can generally be run on Cloudflare’s free plan. Queries with larger result sets may exceed the 10ms CPU time available to Workers on the free plan: in that case you’ll see a Cloudflare error page and will need to upgrade your Cloudflare service.

```javascript
import ws from 'ws';
import ws from 'ws'; // undici also works
import { neonConfig, Pool } from '@neondatabase/serverless';

@@ -58,15 +58,5 @@ neonConfig.webSocketConstructor = ws;

But you can also run your own WebSocket proxy, and configure it to allow onward connections to your own Postgres instances.
But you can also [run your own WebSocket proxy](DEPLOY.md), and configure it to allow onward connections to your own Postgres instances.
First, you'll need to set up the proxy itself somewhere public-facing (or on `localhost` for development). See https://github.com/neondatabase/wsproxy for the Go code and instructions.
There are two ways you can secure this.
1. Set up nginx as a TLS proxy in front of `wsproxy`. Example shell commands to achieve this can be found in [DEPLOY.sh](DEPLOY.sh). Onward traffic to Postgres is not secured by this method, so Postgres should be running on the same machine or be reached over a private network.
2. Use experimental pure-JS Postgres connection encryption via [subtls](https://github.com/jawj/subtls). **Please note that subtls is experimental software and this configuration is not suitable for use in production**. There's no need for nginx in this scenario, and the Postgres connection is encrypted end-to-end. You get this form of encryption if you set `neonConfig.useSecureWebSocket` to `false` and append `?sslmode=verify-full` (or similar) to your connection string. TLS version 1.3 must be supported by the Postgres back-end.
Second, you'll need to set some configuration options on this package, including at a minimum the `wsProxy` option (details below).
## Configuration

@@ -146,3 +136,3 @@

The default is `true`. For non-Neon hosts, set it to `false` instead.
The default is `false`.

@@ -159,2 +149,2 @@ ## Development

* To run the latencies test app in node, create a `.dev.vars` file as above and run `npm run node`. To include debug output and avoid minification, use `npm run nodeDebug` instead.
* To run the latencies test app in node, create a `.dev.vars` file as above and run `npm run node`. To include debug output and avoid minification, use `npm run nodeDebug` instead.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc