-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
27 lines (20 loc) · 839 Bytes
/
server.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
import express from 'express';
import cors from 'cors';
import { createServer } from 'http';
import { injectSocketIO } from './src/lib/server/injectSocketIO.js';
import { handler } from './build/handler.js';
const port = process.env.PORT ? Number(process.env.PORT) : 3000;
const app = express();
const server = createServer(app);
injectSocketIO(server);
app.get('/ping', (_req, res) => {
return res.send({ message: 'pong 🏓' });
});
// SvelteKit should handle everything else, including serving prerendered pages and static assets, using Express middleware
// https://kit.svelte.dev/docs/adapter-node#custom-server
// https://github.com/sveltejs/kit/tree/master/packages/adapter-node#custom-server
app.use(handler);
app.use(cors());
server.listen(port, () => {
console.log(`[ ready ]: Server is running on port ${port}`);
});