initial import

This commit is contained in:
2023-12-27 15:45:49 +01:00
commit c0b7458bf7
20 changed files with 7918 additions and 0 deletions

25
app/lib/sql-shim.ts Normal file
View File

@@ -0,0 +1,25 @@
import { Client, QueryResult, QueryResultRow } from 'pg';
const client = new Client({
// connectionString: process.env.DATABASE_URL,
host: process.env.POSTGRES_HOST,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB
});
client.connect();
/** an adapter function which simulates @vercel/postgres `sql` function */
export function sql<T extends QueryResultRow>(strings: TemplateStringsArray, ...values: any[]): Promise<QueryResult<T>> {
// string values need to be wrapped in single quotes
const fixedValues = values.map((value) => {
if (typeof value === 'string') {
return `'${value}'`;
}
return value;
});
const query = String.raw(strings, ...fixedValues);
return client.query<T>(query);
}