File size: 1,042 Bytes
b859623
 
 
ced6a3b
b859623
 
 
 
 
ced6a3b
b859623
ced6a3b
 
b859623
 
ced6a3b
 
 
 
 
 
 
b859623
 
 
ced6a3b
 
b859623
 
 
 
 
 
 
 
 
 
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
const express = require('express');
const cors = require('cors');
const path = require('path');
const fs = require('fs');

const app = express();
app.use(cors());
app.use(express.static(path.join(__dirname, 'public')));

// Tool registry
const tools = [
  { id: 'trending', name: 'Trending Apps', path: '/api/trending', file: 'trending.js' },
  { id: 'search', name: 'Search Apps', path: '/api/search', file: 'search.js' }
];

// Load tools dynamically
const toolsDir = path.join(__dirname, 'tools');
tools.forEach(tool => {
  const toolPath = path.join(toolsDir, tool.file);
  if (fs.existsSync(toolPath)) {
    require(toolPath)(app);
    console.log(`Loaded tool: ${tool.name}`);
  }
});

app.get('/api/tools', (req, res) => {
  res.json({ tools: tools.map(t => ({ id: t.id, name: t.name, path: t.path })) });
});

app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, 'public', 'index.html'));
});

const PORT = process.env.PORT || 7860;
app.listen(PORT, '0.0.0.0', () => {
  console.log(`Server running on port ${PORT}`);
});