This repository was archived by the owner on Apr 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
65 lines (52 loc) · 1.71 KB
/
Copy pathtest.js
File metadata and controls
65 lines (52 loc) · 1.71 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const express = require("express");
const fs = require("fs");
const path = require("path");
const { createProxyMiddleware } = require('http-proxy-middleware');
require("dotenv").config();
const app = express();
app.use(express.json());
const apiKey = process.env.KEY;
// Proxy setup
app.use('/api', createProxyMiddleware({
target: 'http://localhost:3000', // Target server
changeOrigin: true,
}));
app.get("/gs/frontend", (req, res) => {
const key = req.query.key;
if (key === apiKey) {
fs.readFile('Frontend.js', "utf8", (err, data) => {
if (err) {
return res.status(500).json({ message: "Error reading file" });
}
res.status(200).json({ gs: `${data}` });
});
} else {
res.status(403).json({ message: "Forbidden: Invalid API key" });
}
});
app.get("/gs/backend", (req, res) => {
const key = req.query.key;
if (key === apiKey) {
fs.readFile('Backend.js', "utf8", (err, data) => {
if (err) {
return res.status(500).json({ message: "Error reading file" });
}
res.status(200).json({ gs: `${data}` });
});
} else {
res.status(403).json({ message: "Forbidden: Invalid API key" });
}
});
app.get("/gs/o", (req, res) => {
const key = req.query.key;
if (key === apiKey) {
res.status(200).json({ "O": "jand758@stu.op97.org" });
} else {
res.status(403).json({ message: "Forbidden: Invalid API key" });
}
});
// Listen on all available network interfaces on the specified port or default to 3000
const PORT = process.env.PORT || 3000;
app.listen(PORT, '0.0.0.0', () => {
console.log(`Server is running on port ${PORT}`);
});