Spaces:
Sleeping
Sleeping
Update index.js
Browse files
index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import express from 'express';
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
|
|
@@ -42,6 +43,45 @@ async function getToken(){
|
|
| 42 |
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
//Routes
|
| 46 |
|
| 47 |
app.get('/', (req, res) => {
|
|
@@ -76,6 +116,15 @@ app.get('/creds',async (req,res)=>{
|
|
| 76 |
|
| 77 |
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
// Start
|
| 80 |
|
| 81 |
app.listen(7860, () => console.log('server running on port 7860'));
|
|
|
|
| 1 |
import express from 'express';
|
| 2 |
+
import { algoliasearch } from "algoliasearch";
|
| 3 |
|
| 4 |
|
| 5 |
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
+
const aclient = algoliasearch('D79SNO8B1R', '5e28f0f65380b998763c5251289f6d9b');
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
async function SavetoAlgolia(raw){
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
//const raw = fs.readFileSync("./package.json","utf8");
|
| 54 |
+
const pkg = JSON.parse(raw);
|
| 55 |
+
|
| 56 |
+
const meta = {
|
| 57 |
+
|
| 58 |
+
name: pkg.name,
|
| 59 |
+
description: pkg.description,
|
| 60 |
+
author: pkg.author,
|
| 61 |
+
license: pkg.license,
|
| 62 |
+
version: pkg.version,
|
| 63 |
+
readme:`ihub op clone <mcp server name>`
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
let algolia_insertion=await aclient.saveObject({
|
| 68 |
+
indexName: 'mcp',
|
| 69 |
+
body: meta
|
| 70 |
+
});
|
| 71 |
+
if(algolia_insertion.taskID){
|
| 72 |
+
|
| 73 |
+
return true
|
| 74 |
+
}
|
| 75 |
+
else {
|
| 76 |
+
return false
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
//Routes
|
| 86 |
|
| 87 |
app.get('/', (req, res) => {
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
+
|
| 120 |
+
app.post('/algolia',async (req,res)=>{
|
| 121 |
+
|
| 122 |
+
let {meta}=req.body
|
| 123 |
+
let response=await SavetoAlgolia(meta)
|
| 124 |
+
res.json({"response":response})
|
| 125 |
+
|
| 126 |
+
})
|
| 127 |
+
|
| 128 |
// Start
|
| 129 |
|
| 130 |
app.listen(7860, () => console.log('server running on port 7860'));
|