trying to stop proxy.js from exporting
This commit is contained in:
@@ -96,48 +96,6 @@ function validateConfig(config) {
|
||||
errors.push('Invalid server.port (must be 1-65535)');
|
||||
}
|
||||
|
||||
// Validate consolidated Google Drive settings from global
|
||||
const settings = globalThis['google_drive_settings'];
|
||||
if (!settings) {
|
||||
errors.push('Missing google_drive_settings in global/ directory (required for all functionality)');
|
||||
} else {
|
||||
// Validate service account
|
||||
if (!settings.serviceAccount) {
|
||||
errors.push('Missing serviceAccount in google_drive_settings');
|
||||
} else {
|
||||
if (!settings.serviceAccount.client_email || !settings.serviceAccount.private_key) {
|
||||
errors.push('Invalid serviceAccount format - missing client_email or private_key');
|
||||
}
|
||||
}
|
||||
|
||||
// Validate scopes (optional, will use default if missing)
|
||||
if (settings.scopes) {
|
||||
if (!Array.isArray(settings.scopes) || settings.scopes.length === 0) {
|
||||
errors.push('Invalid scopes (must be a non-empty array)');
|
||||
}
|
||||
} else {
|
||||
logger.warn('No scopes found in google_drive_settings - using default: ["https://www.googleapis.com/auth/drive.readonly"]');
|
||||
}
|
||||
|
||||
// Validate sitemap config (optional)
|
||||
if (settings.sitemap) {
|
||||
if (settings.sitemap.maxUrls && (settings.sitemap.maxUrls < 1 || settings.sitemap.maxUrls > 50000)) {
|
||||
errors.push('Invalid sitemap.maxUrls (must be 1-50000)');
|
||||
}
|
||||
} else {
|
||||
logger.warn('No sitemap config found in google_drive_settings - using default maxUrls: 50000');
|
||||
}
|
||||
|
||||
// Validate drive query (optional)
|
||||
if (settings.driveQuery) {
|
||||
if (typeof settings.driveQuery !== 'string') {
|
||||
errors.push('Invalid driveQuery (must be a string)');
|
||||
}
|
||||
} else {
|
||||
logger.warn('No driveQuery found in google_drive_settings - using default: "trashed = false"');
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
throw new Error(`Configuration validation failed:\n${errors.join('\n')}`);
|
||||
}
|
||||
@@ -165,13 +123,17 @@ async function startServer() {
|
||||
validateConfig(global.config);
|
||||
logger.info('Configuration validated successfully');
|
||||
|
||||
// Import proxy after global.config is set
|
||||
const { handleRequest } = await import('./proxy.js');
|
||||
// Load proxy.js as a function wrapper (ZERO exports per constitution)
|
||||
// Import the module which sets up globalThis.handleRequest
|
||||
await import('./proxy.js');
|
||||
|
||||
// Wrap the global handleRequest function for clean invocation
|
||||
const handleRequest = (req, res) => {
|
||||
return globalThis.handleRequest(req, res);
|
||||
};
|
||||
|
||||
// Create HTTP server that delegates all requests to proxy
|
||||
const server = http.createServer((req, res) => {
|
||||
handleRequest(req, res);
|
||||
});
|
||||
const server = http.createServer(handleRequest);
|
||||
|
||||
// Graceful shutdown
|
||||
const shutdown = () => {
|
||||
|
||||
Reference in New Issue
Block a user