@s-hirano-ist/s-database 1.18.4 → 1.18.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/index.ts +22 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-hirano-ist/s-database",
3
- "version": "1.18.4",
3
+ "version": "1.18.6",
4
4
  "description": "Prisma database schema and client for s-private project",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -29,6 +29,7 @@
29
29
  },
30
30
  "license": "AGPL-3.0",
31
31
  "dependencies": {
32
+ "@prisma/adapter-pg": "7.5.0",
32
33
  "@prisma/client": "7.5.0",
33
34
  "@prisma/client-runtime-utils": "7.5.0",
34
35
  "prisma": "7.5.0"
package/src/index.ts CHANGED
@@ -48,7 +48,29 @@
48
48
  * @see {@link https://www.prisma.io/docs | Prisma Documentation}
49
49
  */
50
50
 
51
+ export { PrismaPg } from "@prisma/adapter-pg";
51
52
  export type { Article, Book, Category, Image, Note } from "./generated";
52
53
  // Re-export everything from generated Prisma client
53
54
  // Note: We use separate exports to maintain proper ESM compatibility
54
55
  export { $Enums, Prisma, PrismaClient, Status } from "./generated";
56
+
57
+ import { PrismaPg } from "@prisma/adapter-pg";
58
+ import { PrismaClient } from "./generated";
59
+
60
+ export function createPrismaClient(databaseUrl: string) {
61
+ const isAccelerate =
62
+ databaseUrl.startsWith("prisma://") ||
63
+ databaseUrl.startsWith("prisma+postgres://");
64
+
65
+ if (isAccelerate) {
66
+ return new PrismaClient({ accelerateUrl: databaseUrl });
67
+ }
68
+ return new PrismaClient({
69
+ adapter: new PrismaPg({
70
+ connectionString: databaseUrl,
71
+ max: 5,
72
+ idleTimeoutMillis: 30_000,
73
+ connectionTimeoutMillis: 10_000,
74
+ }),
75
+ });
76
+ }