-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathtest-ftp-proxy.js
More file actions
48 lines (39 loc) · 1.46 KB
/
test-ftp-proxy.js
File metadata and controls
48 lines (39 loc) · 1.46 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
47
48
/**
* 简单的 FTP 代理测试
*/
import Fastify from 'fastify';
console.log('开始测试 FTP 代理控制器...');
try {
// 测试导入
console.log('1. 测试导入 FTP 代理控制器...');
const ftpProxyController = await import('../controllers/ftp-proxy.js');
console.log('✅ FTP 代理控制器导入成功');
console.log('导入的模块:', typeof ftpProxyController.default);
// 创建 Fastify 实例
console.log('2. 创建 Fastify 实例...');
const fastify = Fastify({
logger: false
});
console.log('✅ Fastify 实例创建成功');
// 注册插件
console.log('3. 注册 FTP 代理控制器插件...');
await fastify.register(ftpProxyController.default);
console.log('✅ FTP 代理控制器插件注册成功');
// 启动服务器
console.log('4. 启动服务器...');
await fastify.listen({ port: 3001, host: '0.0.0.0' });
console.log('✅ 服务器启动成功: http://localhost:3001');
// 测试健康检查
console.log('5. 测试健康检查接口...');
const response = await fetch('http://localhost:3001/ftp/health');
const data = await response.json();
console.log('✅ 健康检查响应:', data);
// 关闭服务器
console.log('6. 关闭服务器...');
await fastify.close();
console.log('✅ 测试完成');
} catch (error) {
console.error('❌ 测试失败:', error);
console.error('错误堆栈:', error.stack);
process.exit(1);
}