-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexpress-node-server.js
More file actions
24 lines (18 loc) · 869 Bytes
/
express-node-server.js
File metadata and controls
24 lines (18 loc) · 869 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
// https:github.com/sveltejs/kit/discussions/10162#discussioncomment-6188946
import { handler } from './build/handler.js';
import express from 'express';
import cron from 'node-cron';
import { cleanUpOriginalsFolder } from './src/lib/server/db/cleanup.js';
// Get absolute path to assets folder, "./data/assets" might work fine and you can remove this line/dep
// const assetsPath = join(import.meta.url, './assets');
const assetsPath = './assets';
const app = express();
// Serve your "assets" folder
app.use(express.static(assetsPath));
// let SvelteKit handle everything else, including serving prerendered pages and static assets
app.use(handler);
// Run the cleanup function every day at 2:30 AM
cron.schedule('30 2 * * *', cleanUpOriginalsFolder, { timezone: process.env.TZ });
app.listen(3000, () => {
console.info('Express: listening on port 3000');
});