-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
59 lines (48 loc) · 1.6 KB
/
server.js
File metadata and controls
59 lines (48 loc) · 1.6 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
const express = require('express');
const path = require('path');
const cors = require('cors');
const session = require('express-session');
const { PORT } = require('./utils/constants');
const { testEncryption } = require('./services/encryption');
const authRoutes = require('./routes/auth');
const fileRoutes = require('./routes/files');
const streamingRoutes = require('./routes/streaming');
const app = express();
// Configure server for large file uploads
app.use(cors({
credentials: true,
origin: true
}));
// Increase payload limits for large files
app.use(express.json({ limit: '50mb' }));
app.use(express.urlencoded({ limit: '50mb', extended: true }));
// Set server timeout for large uploads (5 minutes)
app.use((req, res, next) => {
req.setTimeout(300000); // 5 minutes
res.setTimeout(300000); // 5 minutes
next();
});
app.use(session({
secret: 'your-secret-key-change-in-production',
resave: false,
saveUninitialized: false,
cookie: { secure: false, maxAge: 24 * 60 * 60 * 1000 }
}));
app.use(express.static('public'));
testEncryption();
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
app.get('/public', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'public.html'));
});
app.get('/private', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'private.html'));
});
app.use('/auth', authRoutes);
app.use('/files', fileRoutes);
app.use('/', streamingRoutes);
app.listen(PORT, '0.0.0.0', () => {
console.log(`FelixShare server running on port ${PORT}`);
console.log(`Access from other devices at: http://[YOUR_IP]:${PORT}`);
});