-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
33 lines (28 loc) · 875 Bytes
/
index.js
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
import './lockdown.js';
import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
import { fs } from 'zx';
import router from './router.js';
import { requestLogger } from './middleware/requestLogger.js';
const PORT = 3000;
const UPLOAD_DIR = 'uploads';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
if (!fs.existsSync(UPLOAD_DIR)) {
fs.mkdirSync(UPLOAD_DIR);
}
// Serve static files
app.use(express.static(path.join(__dirname, 'public')));
app.use(
'/scripts/ses',
express.static(path.join(__dirname, 'node_modules/ses/dist'))
);
app.use(express.json({ limit: '50mb' }));
app.use(express.urlencoded({ limit: '50mb', extended: true }));
app.use(requestLogger);
app.use('/', router);
app.listen(PORT, () => {
console.log(`Server listening on ${PORT}`);
});