chore: bump the drizzle and user new pool client.

This commit is contained in:
Yufan Sheng 2024-10-16 10:44:06 +08:00
parent 566334daf5
commit 29891accf2
Signed by: syhily
GPG Key ID: 9D18A22A7DCD5A9B
3 changed files with 37 additions and 44 deletions

44
package-lock.json generated
View File

@ -10,10 +10,10 @@
"license": "MIT",
"dependencies": {
"@astrojs/mdx": "^3.1.8",
"@astrojs/rss": "^4.0.8",
"@astrojs/rss": "^4.0.9",
"@zeabur/astro-adapter": "^1.0.6",
"astro": "^4.16.4",
"drizzle-orm": "^0.34.1",
"astro": "^4.16.5",
"drizzle-orm": "^0.35.0",
"fuse.js": "^7.0.0",
"lodash": "^4.17.21",
"luxon": "^3.5.0",
@ -205,9 +205,9 @@
}
},
"node_modules/@astrojs/rss": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/@astrojs/rss/-/rss-4.0.8.tgz",
"integrity": "sha512-63UYWS2xj00+N79JPiLeHiBBB3nHfjFlJ81T9a+UaYQ7aUZyvU0E9JdZeuONwHKKcSsvP+goPjWmoVifPToRGA==",
"version": "4.0.9",
"resolved": "https://registry.npmjs.org/@astrojs/rss/-/rss-4.0.9.tgz",
"integrity": "sha512-W1qeLc/WP1vMS5xXa+BnaLU0paeSeGjN8RJVAoBaOIkQuKXjIUA9hvPno89heo73in5i67g40gy70oeeHMqp6A==",
"license": "MIT",
"dependencies": {
"fast-xml-parser": "^4.5.0",
@ -2910,9 +2910,9 @@
}
},
"node_modules/astro": {
"version": "4.16.4",
"resolved": "https://registry.npmjs.org/astro/-/astro-4.16.4.tgz",
"integrity": "sha512-W/ETxHRkt9iEAj1RVSqV3bjSGaGXEFJHqeNpPhvJIj720hC3V/ZBDAd6FpMW291eiZPtxhGh+c/VDtkD6avPXQ==",
"version": "4.16.5",
"resolved": "https://registry.npmjs.org/astro/-/astro-4.16.5.tgz",
"integrity": "sha512-v8mKWcEPN7hkfyVsMFWV0F8UgL4GUJKT172KTB7dePO3yJb64HBwCckC0QnA60QQh3jK6+2xwyWEc5QvCeqjtg==",
"license": "MIT",
"dependencies": {
"@astrojs/compiler": "^2.10.3",
@ -3813,9 +3813,9 @@
"license": "MIT"
},
"node_modules/drizzle-orm": {
"version": "0.34.1",
"resolved": "https://registry.npmjs.org/drizzle-orm/-/drizzle-orm-0.34.1.tgz",
"integrity": "sha512-t+zCwyWWt8xTqtYV4doE/xYmT7hpv1L8pQ66zddEz+3VWyedBBtctjMAp22mAJPfyWurRQXUJ1nrTtqLq+DqNA==",
"version": "0.35.0",
"resolved": "https://registry.npmjs.org/drizzle-orm/-/drizzle-orm-0.35.0.tgz",
"integrity": "sha512-fyTKnQ6WZQqSUy6yM4Do2tJPBg1ALR0vJtO9xUTLLubD+0qS1PPuu8aVOeLZQo+g8RPJn+Vqoh30/3lSS8/a2w==",
"license": "Apache-2.0",
"peerDependencies": {
"@aws-sdk/client-rds-data": ">=3",
@ -3950,9 +3950,9 @@
"license": "MIT"
},
"node_modules/electron-to-chromium": {
"version": "1.5.38",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.38.tgz",
"integrity": "sha512-VbeVexmZ1IFh+5EfrYz1I0HTzHVIlJa112UEWhciPyeOcKJGeTv6N8WnG4wsQB81DGCaVEGhpSb6o6a8WYFXXg==",
"version": "1.5.39",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.39.tgz",
"integrity": "sha512-4xkpSR6CjuiaNyvwiWDI85N9AxsvbPawB8xc7yzLPonYTuP19BVgYweKyUMFtHEZgIcHWMt1ks5Cqx2m+6/Grg==",
"license": "ISC"
},
"node_modules/emmet": {
@ -4190,11 +4190,11 @@
}
},
"node_modules/fast-uri": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.2.tgz",
"integrity": "sha512-GR6f0hD7XXyNJa25Tb9BuIdN0tdr+0BMi6/CJPH3wJO1JjNG3n/VsSw38AwRdKZABm8lGbPfakLRkYzx2V9row==",
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.3.tgz",
"integrity": "sha512-aLrHthzCjH5He4Z2H9YZ+v6Ujb9ocRuW6ZzkJQOrTxleEijANq4v1TsaPaVG1PZcuurEzrLcWRyYBYXD5cEiaw==",
"dev": true,
"license": "MIT"
"license": "BSD-3-Clause"
},
"node_modules/fast-xml-parser": {
"version": "4.5.0",
@ -8541,9 +8541,9 @@
}
},
"node_modules/tslib": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz",
"integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==",
"dev": true,
"license": "0BSD",
"optional": true

View File

@ -43,10 +43,10 @@
},
"dependencies": {
"@astrojs/mdx": "^3.1.8",
"@astrojs/rss": "^4.0.8",
"@astrojs/rss": "^4.0.9",
"@zeabur/astro-adapter": "^1.0.6",
"astro": "^4.16.4",
"drizzle-orm": "^0.34.1",
"astro": "^4.16.5",
"drizzle-orm": "^0.35.0",
"fuse.js": "^7.0.0",
"lodash": "^4.17.21",
"luxon": "^3.5.0",

View File

@ -7,27 +7,20 @@ import {
POSTGRES_USERNAME,
} from 'astro:env/server';
import { drizzle } from 'drizzle-orm/node-postgres';
import pg from 'pg';
import type { PoolConfig } from 'pg';
/**
* Cache the database connection in development. This avoids creating a new connection on every HMR update.
*/
const globalForDb = globalThis as unknown as {
conn: pg.Pool | undefined;
};
const conn =
globalForDb.conn ??
new pg.Pool({
host: POSTGRES_HOST,
port: POSTGRES_PORT,
export const db = drizzle({
connection: {
user: POSTGRES_USERNAME,
password: POSTGRES_PASSWORD,
host: POSTGRES_HOST,
port: POSTGRES_PORT,
database: POSTGRES_DATABASE,
keepAlive: true,
max: 10,
min: 1,
allowExitOnIdle: true,
} satisfies PoolConfig,
schema: schema,
logger: false,
});
// Cache the connection.
globalForDb.conn = conn;
export const db = drizzle(conn, { schema: schema, logger: false });