-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-server.js
More file actions
46 lines (41 loc) · 1.3 KB
/
test-server.js
File metadata and controls
46 lines (41 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Simple test to verify server can start without errors
import { createServer } from 'http';
import { parse } from 'url';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
// Mock the storage to avoid initialization issues
const mockStorage = {
getToken: async () => undefined,
createToken: async () => 'test-token',
markTokenUsed: async () => { },
saveReply: async () => { }
};
// Mock the shared schema
const mockSchema = {
replySchema: {
safeParse: () => ({ success: true, data: { choice: 'yes', message: 'test' } })
}
};
// Replace modules with mocks
const Module = require('module');
const originalRequire = Module.prototype.require;
Module.prototype.require = function (...args) {
const moduleName = args[0];
if (moduleName === './storage') {
return { storage: mockStorage };
}
if (moduleName === '@shared/schema') {
return mockSchema;
}
return originalRequire.apply(this, args);
};
try {
// Test importing the server
console.log('Testing server import...');
const { default: serverModule } = await import('./server/index.ts');
console.log('Server imported successfully');
process.exit(0);
} catch (error) {
console.error('Server import failed:', error.message);
process.exit(1);
}