-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (30 loc) · 1013 Bytes
/
Copy pathindex.js
File metadata and controls
40 lines (30 loc) · 1013 Bytes
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
import express from 'express';
import bodyParser from 'body-parser';
import { fileURLToPath } from 'url';
import path from 'path';
// Importing the modules
import pairRouter from './pair.js';
import qrRouter from './qr.js';
import QRCode from 'qrcode';
const app = express();
// Resolve the current directory path in ES modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const PORT = process.env.PORT || 8000;
import('events').then(events => {
events.EventEmitter.defaultMaxListeners = 500;
});
// Middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname));
// Routes
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'pair.html'));
});
app.use('/pair', pairRouter);
app.use('/qr', qrRouter);
app.listen(PORT, () => {
console.log(`YoutTube: @mr_unique_hacker\n\nGitHub: @mruniquehacker\n\nServer running on http://localhost:${PORT}`);
});
export default app;