@friggframework/core 2.0.0--canary.461.e85a4f6.0 → 2.0.0--canary.461.97d93c9.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.
|
@@ -85,11 +85,13 @@ router.use(validateApiKey);
|
|
|
85
85
|
router.post(
|
|
86
86
|
'/db-migrate',
|
|
87
87
|
catchAsyncError(async (req, res) => {
|
|
88
|
-
|
|
88
|
+
// Migration infrastructure is PostgreSQL-only, so hardcode dbType
|
|
89
|
+
const dbType = 'postgresql';
|
|
90
|
+
const { stage } = req.body;
|
|
89
91
|
// TODO: Extract userId from JWT token when auth is implemented
|
|
90
92
|
const userId = req.body.userId || 'admin';
|
|
91
93
|
|
|
92
|
-
console.log(`Migration trigger request: dbType=${dbType}, stage=${stage}, userId=${userId}`);
|
|
94
|
+
console.log(`Migration trigger request: dbType=${dbType}, stage=${stage || 'auto-detect'}, userId=${userId}`);
|
|
93
95
|
|
|
94
96
|
try {
|
|
95
97
|
const result = await triggerMigrationUseCase.execute({
|
|
@@ -173,5 +175,21 @@ router.get(
|
|
|
173
175
|
})
|
|
174
176
|
);
|
|
175
177
|
|
|
176
|
-
|
|
178
|
+
// Minimal Lambda handler (avoids app-handler-helpers which loads core/index.js → user/**)
|
|
179
|
+
const serverlessHttp = require('serverless-http');
|
|
180
|
+
const express = require('express');
|
|
181
|
+
const cors = require('cors');
|
|
182
|
+
|
|
183
|
+
const app = express();
|
|
184
|
+
app.use(cors());
|
|
185
|
+
app.use(express.json());
|
|
186
|
+
app.use(router);
|
|
187
|
+
app.use((err, req, res, next) => {
|
|
188
|
+
console.error('Migration Router Error:', err);
|
|
189
|
+
res.status(500).json({ message: 'Internal Server Error' });
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const handler = serverlessHttp(app);
|
|
193
|
+
|
|
194
|
+
module.exports = { handler, router };
|
|
177
195
|
|
|
@@ -28,21 +28,24 @@ describe('Database Migration Router - Adapter Layer', () => {
|
|
|
28
28
|
it('should load without requiring app definition (critical bug fix)', () => {
|
|
29
29
|
// Before fix: createProcessRepository() → getDatabaseType() → loads app definition → requires integrations → CRASH
|
|
30
30
|
// After fix: ProcessRepositoryPostgres instantiated directly → no app definition → SUCCESS
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
expect(() => {
|
|
33
33
|
require('./db-migration');
|
|
34
34
|
}).not.toThrow();
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
it('should export
|
|
38
|
-
const router = require('./db-migration');
|
|
37
|
+
it('should export handler and router', () => {
|
|
38
|
+
const { handler, router } = require('./db-migration');
|
|
39
|
+
expect(typeof handler).toBe('function');
|
|
39
40
|
expect(typeof router).toBe('function');
|
|
40
41
|
expect(router.stack).toBeDefined();
|
|
41
42
|
});
|
|
42
43
|
|
|
43
|
-
it('should
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
44
|
+
it('should hardcode dbType as postgresql (migrations are PostgreSQL-only)', () => {
|
|
45
|
+
// Migration infrastructure is only created for PostgreSQL deployments
|
|
46
|
+
// So we can safely hardcode dbType instead of requiring it from request
|
|
47
|
+
const router = require('./db-migration').router;
|
|
48
|
+
expect(router).toBeDefined();
|
|
49
|
+
// Test will pass if handler doesn't crash when dbType is omitted from request
|
|
47
50
|
});
|
|
48
51
|
});
|
|
@@ -104,32 +104,32 @@ function sanitizeDatabaseUrl(url) {
|
|
|
104
104
|
*/
|
|
105
105
|
function extractMigrationParams(event) {
|
|
106
106
|
let processId = null;
|
|
107
|
-
let dbType = null;
|
|
108
107
|
let stage = null;
|
|
108
|
+
|
|
109
|
+
// Migration infrastructure is PostgreSQL-only, so hardcode dbType
|
|
110
|
+
const dbType = 'postgresql';
|
|
109
111
|
|
|
110
112
|
// Check if this is an SQS event
|
|
111
113
|
if (event.Records && event.Records.length > 0) {
|
|
112
114
|
// SQS event - extract from message body
|
|
113
115
|
const message = JSON.parse(event.Records[0].body);
|
|
114
116
|
processId = message.processId;
|
|
115
|
-
dbType = message.dbType;
|
|
116
117
|
stage = message.stage;
|
|
117
118
|
|
|
118
119
|
console.log('SQS event detected');
|
|
119
120
|
console.log(` Process ID: ${processId}`);
|
|
120
|
-
console.log(` DB Type: ${dbType}`);
|
|
121
|
+
console.log(` DB Type: ${dbType} (hardcoded - PostgreSQL-only)`);
|
|
121
122
|
console.log(` Stage: ${stage}`);
|
|
122
123
|
} else {
|
|
123
124
|
// Direct invocation - use event properties or environment variables
|
|
124
125
|
processId = event.processId || null;
|
|
125
|
-
dbType = event.dbType || process.env.DB_TYPE || 'postgresql';
|
|
126
126
|
stage = event.stage || process.env.STAGE || 'production';
|
|
127
127
|
|
|
128
128
|
console.log('Direct invocation detected');
|
|
129
129
|
if (processId) {
|
|
130
130
|
console.log(` Process ID: ${processId}`);
|
|
131
131
|
}
|
|
132
|
-
console.log(` DB Type: ${dbType}`);
|
|
132
|
+
console.log(` DB Type: ${dbType} (hardcoded - PostgreSQL-only)`);
|
|
133
133
|
console.log(` Stage: ${stage}`);
|
|
134
134
|
}
|
|
135
135
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.461.
|
|
4
|
+
"version": "2.0.0--canary.461.97d93c9.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@friggframework/eslint-config": "2.0.0--canary.461.
|
|
41
|
-
"@friggframework/prettier-config": "2.0.0--canary.461.
|
|
42
|
-
"@friggframework/test": "2.0.0--canary.461.
|
|
40
|
+
"@friggframework/eslint-config": "2.0.0--canary.461.97d93c9.0",
|
|
41
|
+
"@friggframework/prettier-config": "2.0.0--canary.461.97d93c9.0",
|
|
42
|
+
"@friggframework/test": "2.0.0--canary.461.97d93c9.0",
|
|
43
43
|
"@prisma/client": "^6.17.0",
|
|
44
44
|
"@types/lodash": "4.17.15",
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "97d93c9143829a56c166c50c1127961fba83bfa0"
|
|
83
83
|
}
|