@jayfong/x-server 2.115.0 → 2.116.0

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.
@@ -2,6 +2,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import { URL } from 'node:url';
3
3
  import { x } from '@jayfong/x-server';
4
4
  import { PrismaMariaDb } from '@prisma/adapter-mariadb';
5
+ import { isNumeric, mapValues } from 'vtils';
5
6
  import { type Prisma, PrismaClient } from './prisma/client';
6
7
 
7
8
  const dbUri = new URL(process.env.DATABASE_URL!);
@@ -11,8 +12,18 @@ const adapter = new PrismaMariaDb({
11
12
  user: dbUri.username,
12
13
  password: dbUri.password,
13
14
  database: dbUri.pathname.slice(1),
14
- // @ts-ignore
15
- ...(x.env.PRISMA_ADAPTER_OPTIONS || {}),
15
+ ...mapValues(Object.fromEntries(dbUri.searchParams.entries()), v => {
16
+ return v === 'true'
17
+ ? true
18
+ : v === 'false'
19
+ ? false
20
+ : (isNumeric(v) as boolean)
21
+ ? +v
22
+ : (v[0] === '{' && v[v.length - 1] === '}') ||
23
+ (v[0] === '[' && v[v.length - 1] === ']')
24
+ ? JSON.parse(v)
25
+ : v;
26
+ }),
16
27
  });
17
28
  export const prismaClient = new PrismaClient({ adapter })
18
29
  // https://github.com/prisma/prisma/issues/7550#issuecomment-2437006346
@@ -2,6 +2,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import { URL } from 'node:url';
3
3
  import { x } from '@jayfong/x-server';
4
4
  import { PrismaMariaDb } from '@prisma/adapter-mariadb';
5
+ import { isNumeric, mapValues } from 'vtils';
5
6
  import { type Prisma, PrismaClient } from './prisma/client';
6
7
 
7
8
  const dbUri = new URL(process.env.DATABASE_URL!);
@@ -11,8 +12,18 @@ const adapter = new PrismaMariaDb({
11
12
  user: dbUri.username,
12
13
  password: dbUri.password,
13
14
  database: dbUri.pathname.slice(1),
14
- // @ts-ignore
15
- ...(x.env.PRISMA_ADAPTER_OPTIONS || {}),
15
+ ...mapValues(Object.fromEntries(dbUri.searchParams.entries()), v => {
16
+ return v === 'true'
17
+ ? true
18
+ : v === 'false'
19
+ ? false
20
+ : (isNumeric(v) as boolean)
21
+ ? +v
22
+ : (v[0] === '{' && v[v.length - 1] === '}') ||
23
+ (v[0] === '[' && v[v.length - 1] === ']')
24
+ ? JSON.parse(v)
25
+ : v;
26
+ }),
16
27
  });
17
28
  export const prismaClient = new PrismaClient({ adapter })
18
29
  // https://github.com/prisma/prisma/issues/7550#issuecomment-2437006346
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.115.0",
3
+ "version": "2.116.0",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",