@xenterprises/fastify-xconfig 2.1.1 → 2.1.2
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 +1 -1
- package/CHANGELOG.md +0 -189
- package/server/app.js +0 -43
package/package.json
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
## [2.0.0] - 2025-12-28
|
|
6
|
-
|
|
7
|
-
### BREAKING CHANGES
|
|
8
|
-
|
|
9
|
-
This is a major version release with significant architectural changes.
|
|
10
|
-
|
|
11
|
-
#### Removed Services
|
|
12
|
-
|
|
13
|
-
The following services have been extracted to dedicated plugins and are **no longer** available in xConfig:
|
|
14
|
-
|
|
15
|
-
- **SendGrid Integration** - Use `@xenterprises/fastify-xsendgrid` (planned) or implement separately
|
|
16
|
-
- **Twilio Integration** - Use `@xenterprises/fastify-xtwilio` (planned) or implement separately
|
|
17
|
-
- **Cloudinary Integration** - Use `@xenterprises/fastify-xstorage` (planned) or implement separately
|
|
18
|
-
- **Stripe Integration** - Use `@xenterprises/fastify-xstripe` (planned) or implement separately
|
|
19
|
-
- **Stack Auth Integration** - Use `@xenterprises/fastify-xauth-jwks` instead
|
|
20
|
-
|
|
21
|
-
#### Configuration Changes
|
|
22
|
-
|
|
23
|
-
The following options are **no longer supported** in xConfig registration:
|
|
24
|
-
|
|
25
|
-
```javascript
|
|
26
|
-
// ❌ These options are now REMOVED
|
|
27
|
-
fastify.register(xConfig, {
|
|
28
|
-
sendGrid: { ... }, // REMOVED - use separate plugin
|
|
29
|
-
twilio: { ... }, // REMOVED - use separate plugin
|
|
30
|
-
cloudinary: { ... }, // REMOVED - use separate plugin
|
|
31
|
-
stripe: { ... }, // REMOVED - use separate plugin
|
|
32
|
-
auth: { ... }, // REMOVED - use xAuthJWSK plugin
|
|
33
|
-
geocode: { ... }, // REMOVED - use xGeocode plugin
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
#### New Plugin-Based Architecture
|
|
38
|
-
|
|
39
|
-
xConfig now focuses on core middleware only. Use these dedicated plugins for removed services:
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
import Fastify from 'fastify';
|
|
43
|
-
import xConfig from '@xenterprises/fastify-xconfig';
|
|
44
|
-
import xAuthJWSK from '@xenterprises/fastify-xauth-jwks';
|
|
45
|
-
import xGeocode from '@xenterprises/fastify-xgeocode';
|
|
46
|
-
|
|
47
|
-
const fastify = Fastify();
|
|
48
|
-
|
|
49
|
-
// Core config (middleware & database)
|
|
50
|
-
await fastify.register(xConfig, {
|
|
51
|
-
prisma: {},
|
|
52
|
-
cors: { origin: ['https://example.com'] },
|
|
53
|
-
rateLimit: { max: 100, timeWindow: '1 minute' },
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// Dedicated plugins for other services
|
|
57
|
-
await fastify.register(xAuthJWSK, { /* config */ });
|
|
58
|
-
await fastify.register(xGeocode, { /* config */ });
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Added
|
|
62
|
-
|
|
63
|
-
- ✅ Enhanced CORS security - Environment-aware origin defaults
|
|
64
|
-
- Production: Only allows configured domain
|
|
65
|
-
- Development: Allows localhost:3000 and localhost:3001
|
|
66
|
-
- ✅ Improved health check endpoint - Better environment validation
|
|
67
|
-
- ✅ Test suite - 8 comprehensive tests covering core functionality
|
|
68
|
-
- ✅ Production hardening - Security audit and best practices applied
|
|
69
|
-
|
|
70
|
-
### Changed
|
|
71
|
-
|
|
72
|
-
- **Core Focus**: xConfig now provides only essential middleware and configuration
|
|
73
|
-
- **Plugin Architecture**: Services moved to dedicated, focused plugins
|
|
74
|
-
- **Dependencies**: Reduced from 22 to 11 (50% reduction)
|
|
75
|
-
- **Bundle Size**: ~42% smaller with removed integrations
|
|
76
|
-
- **Code Quality**: Improved maintainability and single responsibility
|
|
77
|
-
|
|
78
|
-
### Fixed
|
|
79
|
-
|
|
80
|
-
- ⚠️ Prisma disconnect hook - Now properly called only once on shutdown
|
|
81
|
-
- ✅ Health endpoint - No longer fails when Prisma is disabled
|
|
82
|
-
- ✅ Lifecycle hooks - Fixed "already listening" errors in test scenarios
|
|
83
|
-
|
|
84
|
-
### Security
|
|
85
|
-
|
|
86
|
-
- **npm audit**: 0 vulnerabilities
|
|
87
|
-
- **CORS**: Secure defaults based on environment
|
|
88
|
-
- **Error Handling**: Stack traces hidden in production
|
|
89
|
-
- **Error Reporting**: Optional Bugsnag integration
|
|
90
|
-
|
|
91
|
-
### Migration Guide
|
|
92
|
-
|
|
93
|
-
#### Before (v1.x)
|
|
94
|
-
|
|
95
|
-
```javascript
|
|
96
|
-
fastify.register(xConfig, {
|
|
97
|
-
sendGrid: { apiKey: '...' },
|
|
98
|
-
twilio: { accountSid: '...', authToken: '...', phoneNumber: '...' },
|
|
99
|
-
cloudinary: { cloudName: '...' },
|
|
100
|
-
auth: { admin: { ... }, user: { ... } },
|
|
101
|
-
geocode: { apiKey: '...' },
|
|
102
|
-
});
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
#### After (v2.0)
|
|
106
|
-
|
|
107
|
-
```javascript
|
|
108
|
-
// Step 1: Core config only
|
|
109
|
-
fastify.register(xConfig, {
|
|
110
|
-
prisma: {},
|
|
111
|
-
cors: { active: true, origin: ['https://yourdomain.com'] },
|
|
112
|
-
rateLimit: { max: 100, timeWindow: '1 minute' },
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// Step 2: Add service plugins
|
|
116
|
-
fastify.register(xAuthJWSK, {
|
|
117
|
-
paths: {
|
|
118
|
-
admin: { pathPattern: '/admin', jwksUrl: '...' },
|
|
119
|
-
api: { pathPattern: '/api', jwksUrl: '...' }
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
fastify.register(xGeocode, {
|
|
124
|
-
apiKey: process.env.GEOCODIO_API_KEY
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// Step 3: Implement other services separately or wait for dedicated plugins
|
|
128
|
-
// - Email: Use SendGrid SDK directly or wait for @xenterprises/fastify-xsendgrid
|
|
129
|
-
// - SMS: Use Twilio SDK directly or wait for @xenterprises/fastify-xtwilio
|
|
130
|
-
// - Storage: Use AWS S3 SDK directly or wait for @xenterprises/fastify-xstorage
|
|
131
|
-
// - Payments: Use Stripe SDK directly or wait for @xenterprises/fastify-xstripe
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Deprecation Notes
|
|
135
|
-
|
|
136
|
-
- The `auth` option is deprecated. Use `@xenterprises/fastify-xauth-jwks` instead
|
|
137
|
-
- The `geocode` option is deprecated. Use `@xenterprises/fastify-xgeocode` instead
|
|
138
|
-
- Stack Auth integration is deprecated. Use `@xenterprises/fastify-xauth-jwks` instead
|
|
139
|
-
|
|
140
|
-
### Environment Variables
|
|
141
|
-
|
|
142
|
-
**Removed** (no longer supported):
|
|
143
|
-
- `ADMIN_STACK_PROJECT_ID`
|
|
144
|
-
- `ADMIN_STACK_PUBLISHABLE_CLIENT_KEY`
|
|
145
|
-
- `ADMIN_STACK_SECRET_SERVER_KEY`
|
|
146
|
-
- `USER_STACK_PROJECT_ID`
|
|
147
|
-
- `USER_STACK_PUBLISHABLE_CLIENT_KEY`
|
|
148
|
-
- `USER_STACK_SECRET_SERVER_KEY`
|
|
149
|
-
- `SENDGRID_API_KEY`
|
|
150
|
-
- `SENDGRID_API_EMAIL_VALIDATION_KEY`
|
|
151
|
-
- `SENDGRID_FROM_EMAIL`
|
|
152
|
-
- `TWILIO_ACCOUNT_SID`
|
|
153
|
-
- `TWILIO_AUTH_TOKEN`
|
|
154
|
-
- `TWILIO_PHONE_NUMBER`
|
|
155
|
-
- `CLOUDINARY_CLOUD_NAME`
|
|
156
|
-
- `CLOUDINARY_API_KEY`
|
|
157
|
-
- `CLOUDINARY_API_SECRET`
|
|
158
|
-
- `CLOUDINARY_BASE_PATH`
|
|
159
|
-
- `STRIPE_API_KEY`
|
|
160
|
-
|
|
161
|
-
**Still Supported**:
|
|
162
|
-
- `DATABASE_URL` - PostgreSQL connection string (if Prisma enabled)
|
|
163
|
-
- `NODE_ENV` - Application environment
|
|
164
|
-
- `PORT` - Server port
|
|
165
|
-
- `FASTIFY_ADDRESS` - Server address
|
|
166
|
-
- `BUGSNAG_API_KEY` - Error tracking (optional)
|
|
167
|
-
- `CORS_ORIGIN` - Allowed CORS origins
|
|
168
|
-
- `RATE_LIMIT_MAX` - Rate limit threshold
|
|
169
|
-
- `RATE_LIMIT_TIME_WINDOW` - Rate limit window
|
|
170
|
-
|
|
171
|
-
### Testing
|
|
172
|
-
|
|
173
|
-
- ✅ All tests passing (8/8)
|
|
174
|
-
- ✅ npm audit clean (0 vulnerabilities)
|
|
175
|
-
- ✅ Production hardening complete
|
|
176
|
-
- ✅ Graceful shutdown verified
|
|
177
|
-
- ✅ Health endpoint validated
|
|
178
|
-
|
|
179
|
-
### Dependencies Updated
|
|
180
|
-
|
|
181
|
-
- Updated `@prisma/client` to ^7.2.0
|
|
182
|
-
- All @fastify packages verified and up-to-date
|
|
183
|
-
- Removed: @sendgrid/mail, @sendgrid/client, twilio, cloudinary, jose, stripe
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## [1.x] - Previous Versions
|
|
188
|
-
|
|
189
|
-
See git history for previous releases.
|
package/server/app.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// server/app.js
|
|
2
|
-
import Fastify from 'fastify';
|
|
3
|
-
import xConfig from '../src/xConfig.js'; // Import your plugin correctly
|
|
4
|
-
|
|
5
|
-
const fastify = Fastify();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export default async function (fastify, opts) {
|
|
9
|
-
fastify.register(xConfig, {
|
|
10
|
-
professional: false,
|
|
11
|
-
fancyErrors: true,
|
|
12
|
-
prisma: {
|
|
13
|
-
active: false,
|
|
14
|
-
},
|
|
15
|
-
bugsnag: {
|
|
16
|
-
apiKey: process.env.BUGSNAG_API_KEY
|
|
17
|
-
},
|
|
18
|
-
rateLimit: {
|
|
19
|
-
max: process.env.RATE_LIMIT_MAX || 100,
|
|
20
|
-
timeWindow: process.env.RATE_LIMIT_TIME_WINDOW || '1 minute'
|
|
21
|
-
},
|
|
22
|
-
cors: {
|
|
23
|
-
active: true,
|
|
24
|
-
origin: process.env.CORS_ORIGIN || ['http://localhost:3000'],
|
|
25
|
-
credentials: true
|
|
26
|
-
},
|
|
27
|
-
multipart: {
|
|
28
|
-
limits: {
|
|
29
|
-
fileSize: 52428800 // 50MB
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
underPressure: {
|
|
33
|
-
maxEventLoopDelay: 1000,
|
|
34
|
-
maxHeapUsedBytes: 1000000000,
|
|
35
|
-
maxRssBytes: 1000000000
|
|
36
|
-
}
|
|
37
|
-
}); // Register the default export, which should be a function
|
|
38
|
-
fastify.get('/', async (request, reply) => {
|
|
39
|
-
console.log(fastify.xEcho())
|
|
40
|
-
return { status: fastify.xEcho() }
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
};
|