forked from Cattn/Maple
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (24 loc) · 871 Bytes
/
server.js
File metadata and controls
31 lines (24 loc) · 871 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
import { handler } from './build/handler.js';
import express from 'express';
import path from 'path';
import * as fs from 'fs';
import http from 'node:http';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const app = express();
const server = http.createServer(app);
const uploadsPath = path.join(__dirname, 'SMS', 'uploads');
if (fs.existsSync(uploadsPath)) {
app.use('/SMS/uploads', express.static(uploadsPath));
app.use('/SMS/uploads', (req, res) => {
res.status(404).send('404, no media found!');
});
app.use('/SMS/upload', (req, res) => {
res.status(404).send('404, did you mean `/SMS/uploads`?');
});
}
// let SvelteKit handle everything else, including serving prerendered pages and static assets
app.use(handler);
server.listen(5000);