Spaces:
Paused
Paused
Download server/src/index.js from secutorpro/dispatch-console: direct link, hf CLI and curl.
- Browser
- Download file 952 Bytes
-
https://huggingface.co/spaces/secutorpro/dispatch-console/resolve/main/server/src/index.js
- Command line
-
hf download hf://spaces/secutorpro/dispatch-console/server/src/index.js
-
curl -L -o index.js https://huggingface.co/spaces/secutorpro/dispatch-console/resolve/main/server/src/index.js
952 Bytes
| import express from 'express'; | |
| import cors from 'cors'; | |
| import http from 'node:http'; | |
| import path from 'node:path'; | |
| import { fileURLToPath } from 'node:url'; | |
| import { WebSocketServer } from 'ws'; | |
| import authRouter, { requireAuth } from './auth.js'; | |
| import routes from './routes.js'; | |
| import Hub from './realtime.js'; | |
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | |
| const PORT = Number(process.env.PORT || 8080); | |
| const app = express(); | |
| app.use(cors()); | |
| app.use(express.json()); | |
| app.use('/api', authRouter); | |
| app.use('/api', requireAuth, routes); | |
| const webDist = path.join(__dirname, '..', 'web', 'dist'); | |
| app.use(express.static(webDist)); | |
| app.get('*', (req, res) => res.sendFile(path.join(webDist, 'index.html'))); | |
| const server = http.createServer(app); | |
| const wss = new WebSocketServer({ server, path: '/ws' }); | |
| const hub = new Hub(wss); | |
| app.set('hub', hub); | |
| server.listen(PORT, () => console.log(`[dispatch] listening on :${PORT}`)); |