2024-12-18 21:47:33 +00:00
|
|
|
const express = require('express');
|
|
|
|
const fetch = require('node-fetch');
|
2024-12-20 00:12:43 +00:00
|
|
|
const cookieParser = require('cookie-parser');
|
2024-12-18 21:47:33 +00:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
|
|
|
|
app.use(express.static('public'));
|
2024-12-20 00:12:43 +00:00
|
|
|
app.use(cookieParser());
|
|
|
|
|
2024-12-20 00:38:42 +00:00
|
|
|
const autoCopyDefault = process.env.AUTO_COPY_DEFAULT === 'true';
|
2024-12-20 00:12:43 +00:00
|
|
|
|
|
|
|
app.get('/auto-copy-default', (req, res) => {
|
|
|
|
res.json({ autoCopyDefault });
|
|
|
|
});
|
2024-12-18 21:47:33 +00:00
|
|
|
|
2024-12-18 22:01:20 +00:00
|
|
|
// Route to handle raw Pastebin requests
|
|
|
|
app.get('/:pasteId', async (req, res) => {
|
|
|
|
const pasteId = req.params.pasteId;
|
|
|
|
const rawUrl = `https://pastebin.com/raw/${pasteId}`;
|
2024-12-18 21:16:43 +00:00
|
|
|
|
2024-12-18 22:01:20 +00:00
|
|
|
try {
|
|
|
|
const response = await fetch(rawUrl);
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error('Failed to fetch data from Pastebin');
|
2024-12-18 21:53:05 +00:00
|
|
|
}
|
2024-12-18 22:01:20 +00:00
|
|
|
const text = await response.text();
|
|
|
|
res.setHeader('Content-Type', 'text/plain'); // Ensure raw text response
|
|
|
|
res.send(text); // Send the raw paste content
|
|
|
|
} catch (error) {
|
|
|
|
res.status(500).json({ error: error.message }); // Return error in JSON format
|
2024-12-18 21:53:05 +00:00
|
|
|
}
|
2024-12-18 21:16:43 +00:00
|
|
|
});
|
2024-12-18 21:47:33 +00:00
|
|
|
|
|
|
|
// Start the server
|
|
|
|
app.listen(PORT, () => {
|
|
|
|
console.log(`Server is running on http://localhost:${PORT}`);
|
|
|
|
});
|