import { handler } from './build/handler.js'; import express from 'express'; import cron from 'node-cron'; import fetch from 'node-fetch'; import dotenv from 'dotenv'; dotenv.config(); const app = express(); // Serve your "data/assets" folder app.use(express.static('data/assets')) // let SvelteKit handle everything else, including serving prerendered pages and static assets app.use(handler); app.listen(3000, () => { console.log('listening on port 3000'); }); cron.schedule("0 * * * *", async () => { console.log('Scraping models') const first_space_host = process.env.SPACE_HOST?.split(',')[0] ?? process.env.SPACE_HOST const request = await fetch(`https://${first_space_host}/api/scrap-models`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-hf-token': process.env.SECRET_HF_TOKEN }, }); const response = await request.json(); console.info(response?.message) }); cron.schedule( "0 0 * * *" , async () => { console.log('Updating models') const first_space_host = process.env.SPACE_HOST?.split(',')[0] ?? process.env.SPACE_HOST const request = await fetch(`http://${first_space_host}/api/models`, { method: 'PATCH', headers: { 'Content-Type': 'application/json', 'x-hf-token': process.env.SECRET_HF_TOKEN }, }); const response = await request.json(); console.info(response?.message) });