import express from "express"; import { Server } from "socket.io"; import http from "http"; import sirv from "sirv"; import * as sapper from "@sapper/server"; import { socketHandler } from "./lib/server-sync"; import { sequelize } from "./lib/models"; const { PORT, NODE_ENV } = process.env; const dev = NODE_ENV === "development"; const app = express(); const server = http.createServer(app); const io = new Server(server); app.use(sirv("static", { dev })); app.use(sapper.middleware()); io.on("connection", socketHandler); async function start() { await sequelize.sync(); const port = PORT || 3000; server.listen(port, () => { console.log("listening on ", port); }); } start();