@feardread/fear 1.0.1
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/FEAR.js +459 -0
- package/FEARServer.js +280 -0
- package/controllers/agent.js +438 -0
- package/controllers/auth/index.js +345 -0
- package/controllers/auth/token.js +50 -0
- package/controllers/blog.js +105 -0
- package/controllers/brand.js +10 -0
- package/controllers/cart.js +425 -0
- package/controllers/category.js +9 -0
- package/controllers/coupon.js +63 -0
- package/controllers/crud/crud.js +508 -0
- package/controllers/crud/index.js +36 -0
- package/controllers/email.js +34 -0
- package/controllers/enquiry.js +65 -0
- package/controllers/events.js +9 -0
- package/controllers/order.js +125 -0
- package/controllers/payment.js +31 -0
- package/controllers/product.js +147 -0
- package/controllers/review.js +247 -0
- package/controllers/tag.js +10 -0
- package/controllers/task.js +10 -0
- package/controllers/upload.js +41 -0
- package/controllers/user.js +401 -0
- package/index.js +7 -0
- package/libs/agent/index.js +561 -0
- package/libs/agent/modules/ai/ai.js +285 -0
- package/libs/agent/modules/ai/chat.js +518 -0
- package/libs/agent/modules/ai/config.js +688 -0
- package/libs/agent/modules/ai/operations.js +787 -0
- package/libs/agent/modules/analyze/api.js +546 -0
- package/libs/agent/modules/analyze/dorks.js +395 -0
- package/libs/agent/modules/ccard/README.md +454 -0
- package/libs/agent/modules/ccard/audit.js +479 -0
- package/libs/agent/modules/ccard/checker.js +674 -0
- package/libs/agent/modules/ccard/payment-processors.json +16 -0
- package/libs/agent/modules/ccard/validator.js +629 -0
- package/libs/agent/modules/code/analyzer.js +303 -0
- package/libs/agent/modules/code/jquery.js +1093 -0
- package/libs/agent/modules/code/react.js +1536 -0
- package/libs/agent/modules/code/refactor.js +499 -0
- package/libs/agent/modules/crypto/exchange.js +564 -0
- package/libs/agent/modules/net/proxy.js +409 -0
- package/libs/agent/modules/security/cve.js +442 -0
- package/libs/agent/modules/security/monitor.js +360 -0
- package/libs/agent/modules/security/scanner.js +300 -0
- package/libs/agent/modules/security/vulnerability.js +506 -0
- package/libs/agent/modules/security/web.js +465 -0
- package/libs/agent/modules/utils/browser.js +492 -0
- package/libs/agent/modules/utils/colorizer.js +285 -0
- package/libs/agent/modules/utils/manager.js +478 -0
- package/libs/cloud/index.js +228 -0
- package/libs/config/db.js +21 -0
- package/libs/config/validator.js +82 -0
- package/libs/db/index.js +318 -0
- package/libs/emailer/imap.js +126 -0
- package/libs/emailer/info.js +41 -0
- package/libs/emailer/smtp.js +77 -0
- package/libs/handler/async.js +3 -0
- package/libs/handler/error.js +66 -0
- package/libs/handler/index.js +161 -0
- package/libs/logger/index.js +49 -0
- package/libs/logger/morgan.js +24 -0
- package/libs/passport/passport.js +109 -0
- package/libs/search/api.js +384 -0
- package/libs/search/features.js +219 -0
- package/libs/search/service.js +64 -0
- package/libs/swagger/config.js +18 -0
- package/libs/swagger/index.js +35 -0
- package/libs/validator/index.js +254 -0
- package/models/blog.js +31 -0
- package/models/brand.js +12 -0
- package/models/cart.js +14 -0
- package/models/category.js +11 -0
- package/models/coupon.js +9 -0
- package/models/customer.js +0 -0
- package/models/enquiry.js +29 -0
- package/models/events.js +13 -0
- package/models/order.js +94 -0
- package/models/product.js +32 -0
- package/models/review.js +14 -0
- package/models/tag.js +10 -0
- package/models/task.js +11 -0
- package/models/user.js +68 -0
- package/package.json +12 -0
- package/routes/agent.js +615 -0
- package/routes/auth.js +13 -0
- package/routes/blog.js +19 -0
- package/routes/brand.js +15 -0
- package/routes/cart.js +105 -0
- package/routes/category.js +16 -0
- package/routes/coupon.js +15 -0
- package/routes/enquiry.js +14 -0
- package/routes/events.js +16 -0
- package/routes/mail.js +170 -0
- package/routes/order.js +19 -0
- package/routes/product.js +22 -0
- package/routes/review.js +11 -0
- package/routes/task.js +12 -0
- package/routes/user.js +17 -0
package/routes/agent.js
ADDED
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
// routes/agent.js - API routes for Security Agent (Updated)
|
|
2
|
+
//const agentController = require('../controllers/agent');
|
|
3
|
+
const agentController = require("../controllers/agent");
|
|
4
|
+
|
|
5
|
+
module.exports = (fear) => {
|
|
6
|
+
const router = fear.createRouter();
|
|
7
|
+
const logger = fear.getLogger();
|
|
8
|
+
const handler = fear.getHandler();
|
|
9
|
+
const validator = fear.getValidator();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @route POST /fear/api/agent/initialize
|
|
13
|
+
* @desc Initialize the security agent
|
|
14
|
+
* @access Public
|
|
15
|
+
*/
|
|
16
|
+
router.post('/initialize', async (req, res) => {
|
|
17
|
+
return agentController.initialize(req, res, handler, logger);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @route POST /fear/api/agent/execute
|
|
22
|
+
* @desc Execute a single command
|
|
23
|
+
* @access Public
|
|
24
|
+
*/
|
|
25
|
+
router.post('/execute', async (req, res) => {
|
|
26
|
+
return agentController.executeCommand(req, res, handler, logger);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @route POST /fear/api/agent/batch
|
|
31
|
+
* @desc Execute multiple commands in sequence
|
|
32
|
+
* @access Public
|
|
33
|
+
*/
|
|
34
|
+
router.post('/batch', async (req, res) => {
|
|
35
|
+
return agentController.executeBatch(req, res, handler, logger);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @route GET /fear/api/agent/commands
|
|
40
|
+
* @desc Get all available commands
|
|
41
|
+
* @access Public
|
|
42
|
+
*/
|
|
43
|
+
router.get('/commands', async (req, res) => {
|
|
44
|
+
return agentController.getCommands(req, res, handler, logger);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @route GET /fear/api/agent/commands/:command
|
|
49
|
+
* @desc Check if a specific command exists
|
|
50
|
+
* @access Public
|
|
51
|
+
*/
|
|
52
|
+
router.get('/commands/:command', async (req, res) => {
|
|
53
|
+
return agentController.checkCommand(req, res, handler, logger);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @route GET /fear/api/agent/status
|
|
58
|
+
* @desc Get agent and module status
|
|
59
|
+
* @access Public
|
|
60
|
+
*/
|
|
61
|
+
router.get('/status', async (req, res) => {
|
|
62
|
+
return agentController.getStatus(req, res, handler, logger);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @route GET /fear/api/agent/history
|
|
67
|
+
* @desc Get command history
|
|
68
|
+
* @access Public
|
|
69
|
+
*/
|
|
70
|
+
router.get('/history', async (req, res) => {
|
|
71
|
+
return agentController.getHistory(req, res, handler, logger);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @route GET /fear/api/agent/version
|
|
76
|
+
* @desc Get agent version information
|
|
77
|
+
* @access Public
|
|
78
|
+
*/
|
|
79
|
+
router.get('/version', async (req, res) => {
|
|
80
|
+
return agentController.getVersion(req, res, handler, logger);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @route POST /fear/api/agent/shutdown
|
|
85
|
+
* @desc Shutdown the agent
|
|
86
|
+
* @access Public
|
|
87
|
+
*/
|
|
88
|
+
router.post('/shutdown', async (req, res) => {
|
|
89
|
+
return agentController.shutdown(req, res, handler, logger);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ============================================
|
|
93
|
+
// MODULE-SPECIFIC ROUTES
|
|
94
|
+
// ============================================
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @route POST /fear/api/agent/ai/setup
|
|
98
|
+
* @desc Setup AI configuration
|
|
99
|
+
* @access Public
|
|
100
|
+
*/
|
|
101
|
+
router.post('/ai/setup', async (req, res) => {
|
|
102
|
+
try {
|
|
103
|
+
const { provider, apiKey } = req.body;
|
|
104
|
+
|
|
105
|
+
if (!provider || !apiKey) {
|
|
106
|
+
return handler.error(res, 'Provider and API key are required', 400);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const result = await agentController.executeCommand(
|
|
110
|
+
{ body: { command: 'ai-setup', args: [provider, apiKey] } },
|
|
111
|
+
res,
|
|
112
|
+
handler,
|
|
113
|
+
logger
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
return result;
|
|
117
|
+
|
|
118
|
+
} catch (error) {
|
|
119
|
+
logger.error('AI setup error:', error);
|
|
120
|
+
return handler.error(res, error.message || 'AI setup failed', 500);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @route POST /fear/api/agent/ai/provider
|
|
126
|
+
* @desc Switch AI provider
|
|
127
|
+
* @access Public
|
|
128
|
+
*/
|
|
129
|
+
router.post('/ai/provider', async (req, res) => {
|
|
130
|
+
try {
|
|
131
|
+
const { provider } = req.body;
|
|
132
|
+
|
|
133
|
+
if (!provider) {
|
|
134
|
+
return handler.error(res, 'Provider is required', 400);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const result = await agentController.executeCommand(
|
|
138
|
+
{ body: { command: 'ai-provider', args: [provider] } },
|
|
139
|
+
res,
|
|
140
|
+
handler,
|
|
141
|
+
logger
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return result;
|
|
145
|
+
|
|
146
|
+
} catch (error) {
|
|
147
|
+
logger.error('AI provider switch error:', error);
|
|
148
|
+
return handler.error(res, error.message || 'Provider switch failed', 500);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @route GET /fear/api/agent/ai/status
|
|
154
|
+
* @desc Get AI module status
|
|
155
|
+
* @access Public
|
|
156
|
+
*/
|
|
157
|
+
router.get('/ai/status', async (req, res) => {
|
|
158
|
+
return agentController.executeCommand(
|
|
159
|
+
{ body: { command: 'ai-status', args: [] } },
|
|
160
|
+
res,
|
|
161
|
+
handler,
|
|
162
|
+
logger
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @route POST /fear/api/agent/scan/ports
|
|
168
|
+
* @desc Scan network ports
|
|
169
|
+
* @access Public
|
|
170
|
+
*/
|
|
171
|
+
router.post('/scan/ports', async (req, res) => {
|
|
172
|
+
try {
|
|
173
|
+
const { target, ports } = req.body;
|
|
174
|
+
|
|
175
|
+
if (!target) {
|
|
176
|
+
return handler.error(res, 'Target is required', 400);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const args = ports ? [target, ports] : [target];
|
|
180
|
+
|
|
181
|
+
const result = await agentController.executeCommand(
|
|
182
|
+
{ body: { command: 'scan-ports', args } },
|
|
183
|
+
res,
|
|
184
|
+
handler,
|
|
185
|
+
logger
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
return result;
|
|
189
|
+
|
|
190
|
+
} catch (error) {
|
|
191
|
+
logger.error('Port scan error:', error);
|
|
192
|
+
return handler.error(res, error.message || 'Port scan failed', 500);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @route POST /fear/api/agent/analyze/code
|
|
198
|
+
* @desc Analyze code file or project
|
|
199
|
+
* @access Public
|
|
200
|
+
*/
|
|
201
|
+
router.post('/analyze/code', async (req, res) => {
|
|
202
|
+
try {
|
|
203
|
+
const { path, type } = req.body;
|
|
204
|
+
|
|
205
|
+
if (!path) {
|
|
206
|
+
return handler.error(res, 'Path is required', 400);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const command = type === 'project' ? 'analyze-project' : 'analyze-code';
|
|
210
|
+
|
|
211
|
+
const result = await agentController.executeCommand(
|
|
212
|
+
{ body: { command, args: [path] } },
|
|
213
|
+
res,
|
|
214
|
+
handler,
|
|
215
|
+
logger
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
return result;
|
|
219
|
+
|
|
220
|
+
} catch (error) {
|
|
221
|
+
logger.error('Code analysis error:', error);
|
|
222
|
+
return handler.error(res, error.message || 'Code analysis failed', 500);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @route POST /fear/api/agent/cve/search
|
|
228
|
+
* @desc Search CVE database
|
|
229
|
+
* @access Public
|
|
230
|
+
*/
|
|
231
|
+
router.post('/cve/search', async (req, res) => {
|
|
232
|
+
try {
|
|
233
|
+
const { query } = req.body;
|
|
234
|
+
|
|
235
|
+
if (!query) {
|
|
236
|
+
return handler.error(res, 'Search query is required', 400);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const result = await agentController.executeCommand(
|
|
240
|
+
{ body: { command: 'search-cve', args: [query] } },
|
|
241
|
+
res,
|
|
242
|
+
handler,
|
|
243
|
+
logger
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
return result;
|
|
247
|
+
|
|
248
|
+
} catch (error) {
|
|
249
|
+
logger.error('CVE search error:', error);
|
|
250
|
+
return handler.error(res, error.message || 'CVE search failed', 500);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @route POST /fear/api/agent/chat
|
|
256
|
+
* @desc Start or send message to AI chat session
|
|
257
|
+
* @access Public
|
|
258
|
+
*/
|
|
259
|
+
router.post('/chat', async (req, res) => {
|
|
260
|
+
try {
|
|
261
|
+
const { message, sessionId } = req.body;
|
|
262
|
+
|
|
263
|
+
if (!message) {
|
|
264
|
+
return handler.error(res, 'Message is required', 400);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const args = sessionId ? [message, sessionId] : [message];
|
|
268
|
+
|
|
269
|
+
const result = await agentController.executeCommand(
|
|
270
|
+
{ body: { command: 'chat-quick', args } },
|
|
271
|
+
res,
|
|
272
|
+
handler,
|
|
273
|
+
logger
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
return result;
|
|
277
|
+
|
|
278
|
+
} catch (error) {
|
|
279
|
+
logger.error('Chat error:', error);
|
|
280
|
+
return handler.error(res, error.message || 'Chat failed', 500);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @route GET /fear/api/agent/chat/history
|
|
286
|
+
* @desc Get chat history
|
|
287
|
+
* @access Public
|
|
288
|
+
*/
|
|
289
|
+
router.get('/chat/history', async (req, res) => {
|
|
290
|
+
return agentController.executeCommand(
|
|
291
|
+
{ body: { command: 'chat-history', args: [] } },
|
|
292
|
+
res,
|
|
293
|
+
handler,
|
|
294
|
+
logger
|
|
295
|
+
);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @route POST /fear/api/agent/chat/clear
|
|
300
|
+
* @desc Clear chat history
|
|
301
|
+
* @access Public
|
|
302
|
+
*/
|
|
303
|
+
router.post('/chat/clear', async (req, res) => {
|
|
304
|
+
return agentController.executeCommand(
|
|
305
|
+
{ body: { command: 'chat-clear', args: [] } },
|
|
306
|
+
res,
|
|
307
|
+
handler,
|
|
308
|
+
logger
|
|
309
|
+
);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @route POST /fear/api/agent/service/start
|
|
314
|
+
* @desc Start a background service
|
|
315
|
+
* @access Public
|
|
316
|
+
*/
|
|
317
|
+
router.post('/service/start', async (req, res) => {
|
|
318
|
+
try {
|
|
319
|
+
const { service } = req.body;
|
|
320
|
+
|
|
321
|
+
if (!service) {
|
|
322
|
+
return handler.error(res, 'Service name is required', 400);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const result = await agentController.executeCommand(
|
|
326
|
+
{ body: { command: 'service-start', args: [service] } },
|
|
327
|
+
res,
|
|
328
|
+
handler,
|
|
329
|
+
logger
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
return result;
|
|
333
|
+
|
|
334
|
+
} catch (error) {
|
|
335
|
+
logger.error('Service start error:', error);
|
|
336
|
+
return handler.error(res, error.message || 'Service start failed', 500);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @route POST /fear/api/agent/service/stop
|
|
342
|
+
* @desc Stop a background service
|
|
343
|
+
* @access Public
|
|
344
|
+
*/
|
|
345
|
+
router.post('/service/stop', async (req, res) => {
|
|
346
|
+
try {
|
|
347
|
+
const { service } = req.body;
|
|
348
|
+
|
|
349
|
+
if (!service) {
|
|
350
|
+
return handler.error(res, 'Service name is required', 400);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const result = await agentController.executeCommand(
|
|
354
|
+
{ body: { command: 'service-stop', args: [service] } },
|
|
355
|
+
res,
|
|
356
|
+
handler,
|
|
357
|
+
logger
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
return result;
|
|
361
|
+
|
|
362
|
+
} catch (error) {
|
|
363
|
+
logger.error('Service stop error:', error);
|
|
364
|
+
return handler.error(res, error.message || 'Service stop failed', 500);
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @route GET /fear/api/agent/service/status
|
|
370
|
+
* @desc Get status of all services
|
|
371
|
+
* @access Public
|
|
372
|
+
*/
|
|
373
|
+
router.get('/service/status', async (req, res) => {
|
|
374
|
+
return agentController.executeCommand(
|
|
375
|
+
{ body: { command: 'service-status', args: [] } },
|
|
376
|
+
res,
|
|
377
|
+
handler,
|
|
378
|
+
logger
|
|
379
|
+
);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* @route GET /fear/api/agent/service/list
|
|
384
|
+
* @desc List all available services
|
|
385
|
+
* @access Public
|
|
386
|
+
*/
|
|
387
|
+
router.get('/service/list', async (req, res) => {
|
|
388
|
+
return agentController.executeCommand(
|
|
389
|
+
{ body: { command: 'service-list', args: [] } },
|
|
390
|
+
res,
|
|
391
|
+
handler,
|
|
392
|
+
logger
|
|
393
|
+
);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* @route POST /fear/api/agent/proxy/configure
|
|
398
|
+
* @desc Configure proxy settings
|
|
399
|
+
* @access Public
|
|
400
|
+
*/
|
|
401
|
+
router.post('/proxy/configure', async (req, res) => {
|
|
402
|
+
try {
|
|
403
|
+
const { provider, apiKey, username, password } = req.body;
|
|
404
|
+
|
|
405
|
+
if (!provider) {
|
|
406
|
+
return handler.error(res, 'Provider is required', 400);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
let command, args;
|
|
410
|
+
|
|
411
|
+
if (provider === 'proxifly') {
|
|
412
|
+
if (!apiKey) {
|
|
413
|
+
return handler.error(res, 'API key is required for Proxifly', 400);
|
|
414
|
+
}
|
|
415
|
+
command = 'configure-proxifly';
|
|
416
|
+
args = [apiKey];
|
|
417
|
+
} else if (provider === 'proxy5') {
|
|
418
|
+
if (!username || !password) {
|
|
419
|
+
return handler.error(res, 'Username and password are required for Proxy5', 400);
|
|
420
|
+
}
|
|
421
|
+
command = 'configure-proxy5';
|
|
422
|
+
args = [username, password];
|
|
423
|
+
} else {
|
|
424
|
+
return handler.error(res, 'Invalid provider. Use "proxifly" or "proxy5"', 400);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const result = await agentController.executeCommand(
|
|
428
|
+
{ body: { command, args } },
|
|
429
|
+
res,
|
|
430
|
+
handler,
|
|
431
|
+
logger
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
return result;
|
|
435
|
+
|
|
436
|
+
} catch (error) {
|
|
437
|
+
logger.error('Proxy configuration error:', error);
|
|
438
|
+
return handler.error(res, error.message || 'Proxy configuration failed', 500);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* @route GET /fear/api/agent/proxy/list
|
|
444
|
+
* @desc List available proxies
|
|
445
|
+
* @access Public
|
|
446
|
+
*/
|
|
447
|
+
router.get('/proxy/list', async (req, res) => {
|
|
448
|
+
return agentController.executeCommand(
|
|
449
|
+
{ body: { command: 'list-proxies', args: [] } },
|
|
450
|
+
res,
|
|
451
|
+
handler,
|
|
452
|
+
logger
|
|
453
|
+
);
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @route POST /fear/api/agent/proxy/select
|
|
458
|
+
* @desc Select and activate a proxy
|
|
459
|
+
* @access Public
|
|
460
|
+
*/
|
|
461
|
+
router.post('/proxy/select', async (req, res) => {
|
|
462
|
+
try {
|
|
463
|
+
const { proxyId } = req.body;
|
|
464
|
+
|
|
465
|
+
if (!proxyId) {
|
|
466
|
+
return handler.error(res, 'Proxy ID is required', 400);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const result = await agentController.executeCommand(
|
|
470
|
+
{ body: { command: 'select-proxy', args: [proxyId] } },
|
|
471
|
+
res,
|
|
472
|
+
handler,
|
|
473
|
+
logger
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
return result;
|
|
477
|
+
|
|
478
|
+
} catch (error) {
|
|
479
|
+
logger.error('Proxy selection error:', error);
|
|
480
|
+
return handler.error(res, error.message || 'Proxy selection failed', 500);
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* @route GET /fear/api/agent/proxy/status
|
|
486
|
+
* @desc Get current proxy status
|
|
487
|
+
* @access Public
|
|
488
|
+
*/
|
|
489
|
+
router.get('/proxy/status', async (req, res) => {
|
|
490
|
+
return agentController.executeCommand(
|
|
491
|
+
{ body: { command: 'proxy-status', args: [] } },
|
|
492
|
+
res,
|
|
493
|
+
handler,
|
|
494
|
+
logger
|
|
495
|
+
);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @route POST /fear/api/agent/card/validate
|
|
500
|
+
* @desc Validate credit card number
|
|
501
|
+
* @access Public
|
|
502
|
+
*/
|
|
503
|
+
router.post('/card/validate', async (req, res) => {
|
|
504
|
+
try {
|
|
505
|
+
const { cardNumber } = req.body;
|
|
506
|
+
|
|
507
|
+
if (!cardNumber) {
|
|
508
|
+
return handler.error(res, 'Card number is required', 400);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const result = await agentController.executeCommand(
|
|
512
|
+
{ body: { command: 'validate-card', args: [cardNumber] } },
|
|
513
|
+
res,
|
|
514
|
+
handler,
|
|
515
|
+
logger
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
return result;
|
|
519
|
+
|
|
520
|
+
} catch (error) {
|
|
521
|
+
logger.error('Card validation error:', error);
|
|
522
|
+
return handler.error(res, error.message || 'Card validation failed', 500);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* @route POST /fear/api/agent/card/check-status
|
|
528
|
+
* @desc Check card payment status
|
|
529
|
+
* @access Public
|
|
530
|
+
*/
|
|
531
|
+
router.post('/card/check-status', async (req, res) => {
|
|
532
|
+
try {
|
|
533
|
+
const { cardNumber, expiry, cvv } = req.body;
|
|
534
|
+
|
|
535
|
+
if (!cardNumber) {
|
|
536
|
+
return handler.error(res, 'Card number is required', 400);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
const args = [cardNumber];
|
|
540
|
+
if (expiry) args.push(expiry);
|
|
541
|
+
if (cvv) args.push(cvv);
|
|
542
|
+
|
|
543
|
+
const result = await agentController.executeCommand(
|
|
544
|
+
{ body: { command: 'check-card-status', args } },
|
|
545
|
+
res,
|
|
546
|
+
handler,
|
|
547
|
+
logger
|
|
548
|
+
);
|
|
549
|
+
|
|
550
|
+
return result;
|
|
551
|
+
|
|
552
|
+
} catch (error) {
|
|
553
|
+
logger.error('Card status check error:', error);
|
|
554
|
+
return handler.error(res, error.message || 'Card status check failed', 500);
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* @route GET /fear/api/agent/crypto/price
|
|
560
|
+
* @desc Get cryptocurrency price
|
|
561
|
+
* @access Public
|
|
562
|
+
*/
|
|
563
|
+
router.get('/crypto/price/:symbol', async (req, res) => {
|
|
564
|
+
try {
|
|
565
|
+
const { symbol } = req.params;
|
|
566
|
+
|
|
567
|
+
if (!symbol) {
|
|
568
|
+
return handler.error(res, 'Cryptocurrency symbol is required', 400);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const result = await agentController.executeCommand(
|
|
572
|
+
{ body: { command: 'crypto-price', args: [symbol] } },
|
|
573
|
+
res,
|
|
574
|
+
handler,
|
|
575
|
+
logger
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
return result;
|
|
579
|
+
|
|
580
|
+
} catch (error) {
|
|
581
|
+
logger.error('Crypto price error:', error);
|
|
582
|
+
return handler.error(res, error.message || 'Crypto price fetch failed', 500);
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* @route POST /fear/api/agent/crypto/convert
|
|
588
|
+
* @desc Convert between cryptocurrencies
|
|
589
|
+
* @access Public
|
|
590
|
+
*/
|
|
591
|
+
router.post('/crypto/convert', async (req, res) => {
|
|
592
|
+
try {
|
|
593
|
+
const { from, to, amount } = req.body;
|
|
594
|
+
|
|
595
|
+
if (!from || !to || !amount) {
|
|
596
|
+
return handler.error(res, 'From, to, and amount are required', 400);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const result = await agentController.executeCommand(
|
|
600
|
+
{ body: { command: 'crypto-convert', args: [from, to, amount] } },
|
|
601
|
+
res,
|
|
602
|
+
handler,
|
|
603
|
+
logger
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
return result;
|
|
607
|
+
|
|
608
|
+
} catch (error) {
|
|
609
|
+
logger.error('Crypto conversion error:', error);
|
|
610
|
+
return handler.error(res, error.message || 'Crypto conversion failed', 500);
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
return router;
|
|
615
|
+
};
|
package/routes/auth.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const Auth = require("../controllers/auth");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const handler = fear.getHandler();
|
|
6
|
+
const validator = fear.getValidator();
|
|
7
|
+
|
|
8
|
+
router.post("/login", handler.async(Auth.login))
|
|
9
|
+
router.post("/logout", handler.async(Auth.logout))
|
|
10
|
+
router.post("/register", handler.async(Auth.register))
|
|
11
|
+
|
|
12
|
+
return router;
|
|
13
|
+
}
|
package/routes/blog.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const Blog = require("../controllers/blog");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const handler = fear.getHandler();
|
|
6
|
+
|
|
7
|
+
router.get("/all", handler.async(Blog.all));
|
|
8
|
+
router.post("/new", handler.async(Blog.create));
|
|
9
|
+
router.put("/likes", handler.async(Blog.likes));
|
|
10
|
+
router.put("/dislikes", handler.async(Blog.dislikes));
|
|
11
|
+
router.get("/sections", handler.async(Blog.sections));
|
|
12
|
+
|
|
13
|
+
router.route("/:id")
|
|
14
|
+
.get(Blog.read)
|
|
15
|
+
.put(Blog.update)
|
|
16
|
+
.delete(Blog.delete);
|
|
17
|
+
|
|
18
|
+
return router;
|
|
19
|
+
}
|
package/routes/brand.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const Brand = require("../controllers/brand");
|
|
2
|
+
|
|
3
|
+
module.exports = (fear) => {
|
|
4
|
+
const router = fear.createRouter();
|
|
5
|
+
const handler = fear.getHandler();
|
|
6
|
+
|
|
7
|
+
router.get("/all", handler.async(Brand.all));
|
|
8
|
+
router.post("/new", Brand.create);
|
|
9
|
+
router.route("/:id")
|
|
10
|
+
.put(Brand.update)
|
|
11
|
+
.get(Brand.read)
|
|
12
|
+
.delete(Brand.delete);
|
|
13
|
+
|
|
14
|
+
return router;
|
|
15
|
+
}
|