Pepguy commited on
Commit
6edd06d
·
verified ·
1 Parent(s): ba92074

Delete db.js

Browse files
Files changed (1) hide show
  1. db.js +0 -42
db.js DELETED
@@ -1,42 +0,0 @@
1
- const { createClient } = require('@supabase/supabase-js');
2
- const MiniSearch = require('minisearch');
3
- // require('dotenv').config();
4
-
5
- // 1. Initialize Supabase
6
- const supabaseUrl = process.env.SUPABASE_URL;
7
- const supabaseKey = process.env.SUPABASE_KEY;
8
- const supabase = createClient(supabaseUrl, supabaseKey);
9
-
10
- // 2. Initialize In-Memory Search Engine
11
- const searchEngine = new MiniSearch({
12
- fields: ['name', 'description', 'keywords'],
13
- storeFields: ['id', 'name', 'description', 'url', 'install_command', 'stars', 'reputation_score'],
14
- searchOptions: { fuzzy: 0.2, prefix: true }
15
- });
16
-
17
- // 3. Hydrate RAM from Supabase
18
- async function hydrateMemory() {
19
- console.log("💧 Hydrating In-Memory Index from Supabase...");
20
- try {
21
- const { data, error } = await supabase
22
- .from('mcp_tools')
23
- .select('*');
24
-
25
- if (error) throw error;
26
-
27
- searchEngine.removeAll();
28
- if (data && data.length > 0) {
29
- searchEngine.addAll(data);
30
- }
31
- console.log(`✅ Loaded ${data.length} tools into RAM.`);
32
- } catch (error) {
33
- console.error("❌ Hydration Failed:", error.message);
34
- }
35
- }
36
-
37
- function searchTools(query) {
38
- if (searchEngine.documentCount === 0) return [];
39
- return searchEngine.search(query);
40
- }
41
-
42
- module.exports = { supabase, searchEngine, hydrateMemory, searchTools };