-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
22 lines (16 loc) · 706 Bytes
/
main.ts
File metadata and controls
22 lines (16 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { Elysia } from 'elysia';
import fs from 'node:fs';
const blacklist = fs.readFileSync('./blacklist.txt', 'utf-8').split('\n');
const exclusions = fs.readFileSync('./exclusions.txt', 'utf-8').split('\n')
const app = new Elysia()
app.get('/', (req) => {
const url = req.query.url
if (!url) return new Response('No URL provided', { status: 400 });
const domain = new URL(url).hostname;
if (blacklist.includes(domain) && !exclusions.includes(domain)) {
return new Response('URL is blacklisted', { status: 403 });
}
return new Response('URL is not blacklisted', { status: 200 });
});
app.listen(process.env.PORT || 3000);
console.log(`Listening on ${app.server!.url}`);