Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

node_modules
build
/.idea
16 changes: 16 additions & 0 deletions src/httpQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,22 @@ export function neon<
headers['Neon-Batch-Deferrable'] = String(resolvedDeferrable);
}

const isBrowser =
typeof window !== 'undefined' && typeof document !== 'undefined';
if (isBrowser) {
console.warn(`
************************************************************
* *
* WARNING: Running SQL directly from the browser can have *
* security implications. While your database is protected *
* by Row-Level Security (RLS), use it at your own risk. *
* This approach is great for fast prototyping, but ensure *
* proper safeguards are in place to prevent misuse or *
* execution of expensive SQL queries by your end users. *
* *
************************************************************`);
}

// --- run query ---

let response;
Expand Down
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ circumstances are right.
import type { ClientBase as PgClientBase } from 'pg';
import { type SocketDefaults } from './shims/net';

// Ensure we are very explicit while using these apis. This ensures more type safety
// specially since this library is made to run both in the browser and node.js environments.
declare global {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was mainly to avoid adding dom types globally to the tsconfig. It makes it more type safe

const window: Window | undefined;
const document: Document | undefined;

interface Window {}
interface Document {}
}

export * from './httpQuery';
export * from './sqlTemplate';
export type * from './httpTypes';
Expand Down