-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 05703a8
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Pliki środowiskowe | ||
.env | ||
# Express.js ignore files | ||
node_modules/ | ||
dist/ | ||
|
||
package-lock.json | ||
*.log | ||
*.gz | ||
*.log | ||
|
||
/.vscode | ||
/.idea | ||
*.tmp | ||
*.temp | ||
*.bak | ||
|
||
# Logi błędów | ||
npm-debug.log* | ||
|
||
# Plik konfiguracyjny Yarn | ||
.yarn | ||
|
||
# Pliki tymczasowe Windows | ||
Thumbs.db | ||
Desktop.ini | ||
$RECYCLE.BIN/ | ||
|
||
# Pliky Visual Studio Code | ||
.vscode/ | ||
*.code-workspace | ||
|
||
# Katalog yarn cache | ||
.yarn/cache/ | ||
.yarn/unplugged/ | ||
.yarn/build-state.yml | ||
|
||
# Katalogi specyficzne dla różnych narzędzi | ||
.idea/ | ||
.eslintcache | ||
.pnp/ | ||
.pnpm/ | ||
npm-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const express = require("express"); | ||
const axios = require("axios"); | ||
|
||
const app = express(); | ||
const port = 3001; | ||
app.listen(port, () => console.log(`Server listening on port ${port}`)); | ||
app.use(express.json()); | ||
|
||
app.use((req, res, next) => { | ||
res.header("Access-Control-Allow-Origin", "*"); | ||
next(); | ||
}); | ||
|
||
app.get("/", (req, res) => { | ||
res.send("Just a simple proxy server."); | ||
}); | ||
|
||
app.get("/getEncode/:path", async (req, res) => { | ||
console.log("Received request to /getTest with path:", req.params.path); | ||
|
||
const response = await axios.get(req.params.path); | ||
res.json(response.data); | ||
}); | ||
|
||
app.get("/getNormal/:path(*)", async (req, res) => { | ||
try { | ||
const decodedPath = decodeURIComponent(req.params.path); | ||
console.log("Received request to /getNormal with path:", decodedPath); | ||
|
||
const response = await axios.get(decodedPath, { | ||
params: req.query, | ||
}); | ||
|
||
res.json(response.data); | ||
} catch (error) { | ||
console.error("Error in /getNormal endpoint:", error); | ||
res.status(500).json({ | ||
error: "Wystąpił błąd podczas przetwarzania zapytania API.", | ||
parm: req.params.path, | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "expressproxy", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "nodemon index.js" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"axios": "^1.6.3", | ||
"express": "^4.18.2" | ||
}, | ||
"devDependencies": { | ||
"nodemon": "^3.0.2" | ||
} | ||
} |