@xenterprises/fastify-xconfig 2.1.2 → 2.1.4
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 +2 -2
- package/src/integrations/prisma.js +7 -13
- package/.env +0 -33
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xenterprises/fastify-xconfig",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.4",
|
|
5
5
|
"description": "Fastify configuration plugin for setting up middleware, services, and route handling.",
|
|
6
6
|
"main": "src/xConfig.js",
|
|
7
7
|
"scripts": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@fastify/rate-limit": "^10.0.0",
|
|
34
34
|
"@fastify/sensible": "^6.0.0",
|
|
35
35
|
"@fastify/under-pressure": "^9.0.0",
|
|
36
|
-
"@prisma/client": "^7.
|
|
36
|
+
"@prisma/client": "^7.3.0",
|
|
37
37
|
"check-disk-space": "^3.4.0",
|
|
38
38
|
"fastify": "^5.1.0",
|
|
39
39
|
"fastify-bugsnag": "^5.0.0",
|
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import { PrismaClient } from "@prisma/client";
|
|
3
1
|
export async function setupPrisma(fastify, options) {
|
|
4
2
|
if (options.active !== false) {
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const { client: PrismaClient, active, ...prismaOptions } = options;
|
|
4
|
+
if (!PrismaClient) {
|
|
5
|
+
throw new Error("prisma.client is required - pass your PrismaClient class from your generated client");
|
|
6
|
+
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
await prisma.$connect();
|
|
8
|
+
const prisma = new PrismaClient(prismaOptions);
|
|
10
9
|
|
|
11
|
-
// Decorate Fastify instance with Prisma Client
|
|
12
10
|
fastify.decorate("prisma", prisma);
|
|
13
11
|
|
|
14
|
-
// Disconnect Prisma Client when Fastify closes
|
|
15
12
|
fastify.addHook("onClose", async () => {
|
|
16
13
|
await fastify.prisma.$disconnect();
|
|
17
14
|
});
|
|
18
15
|
|
|
19
16
|
console.info(" ✅ Prisma Enabled");
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
===== Ensure Proper Cleanup on Server Shutdown =====
|
|
23
|
-
*/
|
|
18
|
+
|
|
24
19
|
fastify.addHook("onClose", async () => {
|
|
25
20
|
if (fastify.prisma) {
|
|
26
21
|
await fastify.prisma.$disconnect();
|
|
27
22
|
}
|
|
28
|
-
// Add additional cleanup for other services if necessary
|
|
29
23
|
});
|
|
30
|
-
}
|
|
24
|
+
}
|
package/.env
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# Environment variables for xConfig Plugin
|
|
2
|
-
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
|
3
|
-
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
|
4
|
-
|
|
5
|
-
# Database Configuration (Required)
|
|
6
|
-
DATABASE_URL="postgresql://user:password@localhost:5432/dbname?sslmode=require"
|
|
7
|
-
|
|
8
|
-
# Server Configuration
|
|
9
|
-
NODE_ENV=development
|
|
10
|
-
PORT=3002
|
|
11
|
-
FASTIFY_ADDRESS=0.0.0.0
|
|
12
|
-
|
|
13
|
-
# Error Tracking (optional)
|
|
14
|
-
BUGSNAG_API_KEY="your-bugsnag-api-key"
|
|
15
|
-
|
|
16
|
-
# CORS Configuration (optional)
|
|
17
|
-
CORS_ORIGIN="http://localhost:3000,https://example.com"
|
|
18
|
-
RATE_LIMIT_MAX=100
|
|
19
|
-
RATE_LIMIT_TIME_WINDOW="1 minute"
|
|
20
|
-
|
|
21
|
-
# ========================================
|
|
22
|
-
# DEPRECATED / NO LONGER USED BY XCONFIG
|
|
23
|
-
# ========================================
|
|
24
|
-
# The following services have been extracted to separate plugins:
|
|
25
|
-
#
|
|
26
|
-
# Authentication → Use @xenterprises/fastify-xauth-jwks
|
|
27
|
-
# Geolocation → Use @xenterprises/fastify-xgeocode
|
|
28
|
-
# SMS Services → Use xTwilio plugin (separate module)
|
|
29
|
-
# Email Services → Use separate email plugin
|
|
30
|
-
# Image/File Storage → Use xStorage plugin (separate module)
|
|
31
|
-
# Payment Processing → Use xStripe plugin (separate module)
|
|
32
|
-
#
|
|
33
|
-
# Old Stack Auth variables are deprecated - use xAuthJWSK instead
|