create-protobase 0.43.2 → 0.44.1

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.
@@ -1,20 +1,17 @@
1
1
  import { PostgresDialect } from 'kysely'
2
2
  import pg from 'pg'
3
- import { betterAuthAuthenticator, createAuth, handleDroppedConnections } from '@protobase/server'
3
+ import { appPool, betterAuthAuthenticator, createAuth } from '@protobase/server'
4
4
  import { databaseUrl } from '../db/connection'
5
5
 
6
6
  const secret = process.env.BETTER_AUTH_SECRET
7
7
  if (!secret) throw new Error('BETTER_AUTH_SECRET is not set; generate one with `openssl rand -base64 32` and put it in .env')
8
8
 
9
- // One pool across hot reloads of this module
10
- const store = globalThis as { __erpAdminPool?: pg.Pool }
11
- store.__erpAdminPool ??= handleDroppedConnections(new pg.Pool({ connectionString: databaseUrl, max: 5 }))
9
+ // The app's one pool, shared with the runtime, so the store opens no connections beyond the app's
10
+ const pool = appPool(pg, databaseUrl)
12
11
 
13
12
  /** The admin store (Better Auth's users, sessions and signing keys) lives in this schema, next to the ERP's own schemas. */
14
13
  export const authSchema = 'auth'
15
14
 
16
- const pool = store.__erpAdminPool
17
-
18
15
  // The ERP's records name their organization by core.organizations' integer id, so a new organization takes the next
19
16
  // value of that table's sequence, and gets its row there with the ERP's own settings once it is made.
20
17
  const nextOrganizationId = async () => {
@@ -16,11 +16,11 @@
16
16
  "dev": "protobase dev"
17
17
  },
18
18
  "dependencies": {
19
- "@protobase/cli": ">=0.43.2 <1",
20
- "@protobase/layout": ">=0.43.2 <1",
21
- "@protobase/schema": ">=0.43.2 <1",
22
- "@protobase/server": ">=0.43.2 <1",
23
- "@protobase/ui": ">=0.43.2 <1",
19
+ "@protobase/cli": ">=0.44.1 <1",
20
+ "@protobase/layout": ">=0.44.1 <1",
21
+ "@protobase/schema": ">=0.44.1 <1",
22
+ "@protobase/server": ">=0.44.1 <1",
23
+ "@protobase/ui": ">=0.44.1 <1",
24
24
  "better-auth": "^1.7.12",
25
25
  "jose": "^6.2.12",
26
26
  "kysely": "^0.29.6",
@@ -1,20 +1,17 @@
1
1
  import { PostgresDialect } from 'kysely'
2
2
  import pg from 'pg'
3
- import { betterAuthAuthenticator, createAuth, handleDroppedConnections } from '@protobase/server'
3
+ import { appPool, betterAuthAuthenticator, createAuth } from '@protobase/server'
4
4
  import { databaseUrl } from '../db/connection'
5
5
 
6
6
  const secret = process.env.BETTER_AUTH_SECRET
7
7
  if (!secret) throw new Error('BETTER_AUTH_SECRET is not set; generate one with `openssl rand -base64 32` and put it in .env')
8
8
 
9
- // One pool across hot reloads of this module
10
- const store = globalThis as { __realEstateAdminPool?: pg.Pool }
11
- store.__realEstateAdminPool ??= handleDroppedConnections(new pg.Pool({ connectionString: databaseUrl, max: 5 }))
9
+ // The app's one pool, shared with the runtime, so the store opens no connections beyond the app's
10
+ const pool = appPool(pg, databaseUrl)
12
11
 
13
12
  /** The admin store (Better Auth's users, sessions and signing keys) lives in this schema, next to the example's own schemas. */
14
13
  export const authSchema = 'auth'
15
14
 
16
- const pool = store.__realEstateAdminPool
17
-
18
15
  // Tickets name their assignee by core.users' integer id, so a new user takes the next value of that table's sequence;
19
16
  // their row there comes with the account (db/migrations/013_auth_users.sql).
20
17
  const nextUserId = async () => {
@@ -16,11 +16,11 @@
16
16
  "dev": "protobase dev"
17
17
  },
18
18
  "dependencies": {
19
- "@protobase/cli": ">=0.43.2 <1",
20
- "@protobase/layout": ">=0.43.2 <1",
21
- "@protobase/schema": ">=0.43.2 <1",
22
- "@protobase/server": ">=0.43.2 <1",
23
- "@protobase/ui": ">=0.43.2 <1",
19
+ "@protobase/cli": ">=0.44.1 <1",
20
+ "@protobase/layout": ">=0.44.1 <1",
21
+ "@protobase/schema": ">=0.44.1 <1",
22
+ "@protobase/server": ">=0.44.1 <1",
23
+ "@protobase/ui": ">=0.44.1 <1",
24
24
  "better-auth": "^1.7.12",
25
25
  "jose": "^6.2.12",
26
26
  "kysely": "^0.29.6",
@@ -1,20 +1,19 @@
1
1
  import { PostgresDialect } from 'kysely'
2
2
  import pg from 'pg'
3
- import { betterAuthAuthenticator, createAuth, handleDroppedConnections } from '@protobase/server'
3
+ import { appPool, betterAuthAuthenticator, createAuth } from '@protobase/server'
4
4
  import { databaseUrl } from '../db/connection'
5
5
 
6
6
  const secret = process.env.BETTER_AUTH_SECRET
7
7
  if (!secret) throw new Error('BETTER_AUTH_SECRET is not set; generate one with `openssl rand -base64 32` and put it in .env')
8
8
 
9
- // One pool across hot reloads of this module
10
- const store = globalThis as { __adminPool?: pg.Pool }
11
- store.__adminPool ??= handleDroppedConnections(new pg.Pool({ connectionString: databaseUrl, max: 5 }))
9
+ // The app's one pool, shared with the runtime, so the store opens no connections beyond the app's
10
+ const pool = appPool(pg, databaseUrl)
12
11
 
13
12
  /** The admin store (Better Auth's users, sessions and signing keys) lives in this schema, next to the app's own schemas. */
14
13
  export const authSchema = 'auth'
15
14
 
16
15
  export const auth = createAuth({
17
- database: { dialect: new PostgresDialect({ pool: store.__adminPool }), type: 'postgres', schemaName: authSchema, transaction: true },
16
+ database: { dialect: new PostgresDialect({ pool }), type: 'postgres', schemaName: authSchema, transaction: true },
18
17
  baseURL: process.env.BETTER_AUTH_URL ?? 'http://localhost:5173',
19
18
  secret,
20
19
  // No defaultRole on purpose: every account is created with an explicit role (`protobase users create --role`).
@@ -13,11 +13,11 @@
13
13
  "dev": "protobase dev"
14
14
  },
15
15
  "dependencies": {
16
- "@protobase/cli": ">=0.43.2 <1",
17
- "@protobase/layout": ">=0.43.2 <1",
18
- "@protobase/schema": ">=0.43.2 <1",
19
- "@protobase/server": ">=0.43.2 <1",
20
- "@protobase/ui": ">=0.43.2 <1",
16
+ "@protobase/cli": ">=0.44.1 <1",
17
+ "@protobase/layout": ">=0.44.1 <1",
18
+ "@protobase/schema": ">=0.44.1 <1",
19
+ "@protobase/server": ">=0.44.1 <1",
20
+ "@protobase/ui": ">=0.44.1 <1",
21
21
  "better-auth": "^1.7.12",
22
22
  "jose": "^6.2.12",
23
23
  "kysely": "^0.29.6",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-protobase",
3
- "version": "0.43.2",
3
+ "version": "0.44.1",
4
4
  "description": "npm create protobase: starts a new Protobase project from one of its presets.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {