Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
161 changes: 161 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"type": "module",
"scripts": {
"typecheck": "tsc --project tsconfig.json",
"build": "tsc --project tsconfig.build.json",
"build": "tsc --project tsconfig.build.json && node scripts/copy-migrations.mjs",
"test": "npm run build --silent && sh -c 'node --test \"$@\" test/*.test.mjs' --",
"lint": "npx --yes oxlint@1.56.0 $(find src -type d -name upstream -prune -o -name '*.ts' -print) $(find test -name '*.mjs' -print)"
},
"dependencies": {
"pg": "^8.20.0"
}
}
7 changes: 7 additions & 0 deletions scripts/copy-migrations.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { cpSync } from 'node:fs';

cpSync(
'src/subsystems/supabase/migrations',
'dist/subsystems/supabase/migrations',
{ recursive: true },
);
24 changes: 24 additions & 0 deletions src/@types/node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ declare namespace NodeJS {
SERVICE_NAME?: string;
NODE_ENV?: string;
PORT?: string;
RELATIONAL_BACKEND?: string;
DATABASE_URL?: string;
DATABASE_SCHEMA?: string;
POSTGRES_AUTO_MIGRATE?: string;
}
}

declare const process: {
env: NodeJS.ProcessEnv;
};

declare class Buffer extends Uint8Array {
static from(data: string | ArrayLike<number>): Buffer;
toString(encoding?: string): string;
}

declare module "node:http" {
export interface IncomingMessage {
method?: string;
Expand All @@ -26,7 +35,9 @@ declare module "node:http" {
}

export interface Server {
listening: boolean;
listen(port?: number): Server;
close(callback?: (error?: Error) => void): Server;
once(event: string, listener: (...args: any[]) => void): Server;
off(event: string, listener: (...args: any[]) => void): Server;
}
Expand All @@ -38,3 +49,16 @@ declare module "node:http" {
) => void,
): Server;
}

declare module "node:crypto" {
export function timingSafeEqual(a: Buffer, b: Buffer): boolean;
export function createHash(algorithm: string): {
update(data: string): { digest(): Buffer };
};
}

declare module "node:fs" {
export function readFileSync(path: string | URL, encoding: "utf8"): string;
export function readdirSync(path: string | URL): string[];
export function existsSync(path: string | URL): boolean;
}
28 changes: 28 additions & 0 deletions src/@types/pg/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
declare module "pg" {
export interface QueryResult<Row = any> {
rows: Row[];
rowCount: number | null;
}

export interface PoolConfig {
connectionString?: string;
}

export class Pool {
constructor(config?: PoolConfig);
query<Row = any>(
text: string,
values?: readonly unknown[],
): Promise<QueryResult<Row>>;
connect(): Promise<PoolClient>;
end(): Promise<void>;
}

export interface PoolClient {
query<Row = any>(
text: string,
values?: readonly unknown[],
): Promise<QueryResult<Row>>;
release(err?: Error | boolean): void;
}
}
Loading