adding isTor proxy api

This commit is contained in:
sairaj mote 2024-01-16 04:03:35 +05:30
parent f0eef56973
commit 0d426e30a8
4 changed files with 19 additions and 4 deletions

View File

@ -44,14 +44,13 @@ const hash = require('./routes/hash')
app.use("/hash", hash);
const priceHistory = require('./routes/price-history')
app.use("/price-history", priceHistory);
const isTor = require('./routes/is-tor')
app.use("/is-tor", isTor);
// Start the server
app.listen(PORT, HOST, () => {
console.log(`Server is running at http://${HOST}:${PORT}`);
});
// TODO
//https://utility-api.ranchimall.net/hash/gitwh
// Export the Express API
module.exports = app;

2
index.min.js vendored
View File

@ -1 +1 @@
require("dotenv").config();const express=require("express"),mongoose=require("mongoose"),cors=require("cors"),rateLimit=require("express-rate-limit"),path=require("path"),app=express(),PORT=process.env.PORT||3e3,HOST=process.env.HOST||"127.0.0.1";app.use(express.json()),app.use(cors()),app.use(rateLimit({windowMs:6e4,max:30})),mongoose.connect(`mongodb://${HOST}/price-history`);const db=mongoose.connection;db.on("error",console.error.bind(console,"connection error:")),db.once("open",(()=>{console.log("Connected to MongoDB")})),app.get("/",((req,res)=>{res.sendFile(path.join(__dirname,"./index.min.html"))}));const hash=require("./routes/hash");app.use("/hash",hash);const priceHistory=require("./routes/price-history");app.use("/price-history",priceHistory),app.listen(PORT,HOST,(()=>{console.log(`Server is running at http://${HOST}:${PORT}`)})),module.exports=app;
require("dotenv").config();const express=require("express"),mongoose=require("mongoose"),cors=require("cors"),rateLimit=require("express-rate-limit"),path=require("path"),app=express(),PORT=process.env.PORT||3e3,HOST=process.env.HOST||"127.0.0.1";app.use(express.json()),app.use(cors()),app.use(rateLimit({windowMs:6e4,max:30})),mongoose.connect(`mongodb://${HOST}/price-history`);const db=mongoose.connection;db.on("error",console.error.bind(console,"connection error:")),db.once("open",(()=>{console.log("Connected to MongoDB")})),app.get("/",((req,res)=>{res.sendFile(path.join(__dirname,"./index.min.html"))}));const hash=require("./routes/hash");app.use("/hash",hash);const priceHistory=require("./routes/price-history");app.use("/price-history",priceHistory);const isTor=require("./routes/is-tor");app.use("/is-tor",isTor),app.listen(PORT,HOST,(()=>{console.log(`Server is running at http://${HOST}:${PORT}`)})),module.exports=app;

15
routes/is-tor.js Normal file
View File

@ -0,0 +1,15 @@
const express = require('express');
const router = express.Router();
const axios = require('axios');
router.get('/', async (req, res) => {
try {
const response = await axios.get('https://check.torproject.org/api/ip');
const isTor = response.data.IsTor;
res.json({ isTor });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
module.exports = router;

1
routes/is-tor.min.js vendored Normal file
View File

@ -0,0 +1 @@
const express=require("express"),router=express.Router(),axios=require("axios");router.get("/",(async(req,res)=>{try{const isTor=(await axios.get("https://check.torproject.org/api/ip")).data.IsTor;res.json({isTor:isTor})}catch(error){res.status(500).json({error:error.message})}})),module.exports=router;