servcraft 0.4.3 → 0.4.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "servcraft",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "A modular, production-ready Node.js backend framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,6 +17,7 @@
17
17
  "lint:fix": "eslint src --ext .ts --fix",
18
18
  "format": "prettier --write \"src/**/*.ts\"",
19
19
  "prepare": "husky",
20
+ "postinstall": "prisma generate --schema=./prisma/schema.prisma || true",
20
21
  "typecheck": "tsc --noEmit",
21
22
  "db:generate": "prisma generate",
22
23
  "db:migrate": "prisma migrate dev",
@@ -13,12 +13,21 @@ const prismaClientSingleton = (): PrismaClient => {
13
13
  });
14
14
  };
15
15
 
16
- // Use singleton pattern to prevent multiple instances in development
17
- export const prisma = globalThis.__prisma ?? prismaClientSingleton();
18
-
19
- if (!isProduction()) {
20
- globalThis.__prisma = prisma;
21
- }
16
+ // Lazy initialization - only create client when accessed
17
+ let _prisma: PrismaClient | undefined;
18
+
19
+ export const prisma = new Proxy({} as PrismaClient, {
20
+ get(target, prop) {
21
+ // Initialize on first access
22
+ if (!_prisma) {
23
+ _prisma = globalThis.__prisma ?? prismaClientSingleton();
24
+ if (!isProduction()) {
25
+ globalThis.__prisma = _prisma;
26
+ }
27
+ }
28
+ return (_prisma as any)[prop];
29
+ },
30
+ });
22
31
 
23
32
  export async function connectDatabase(): Promise<void> {
24
33
  try {
package/tsup.config.ts CHANGED
@@ -11,4 +11,5 @@ export default defineConfig({
11
11
  target: 'node18',
12
12
  outDir: 'dist',
13
13
  shims: true,
14
+ external: ['@prisma/client'],
14
15
  });