Репозитории /
Promptly /
server.js
server.js
| 1 | const express = require('express'); |
| 2 | const http = require('http'); |
| 3 | const { setupWebSocket } = require('./server/ws'); |
| 4 | const apiRouter = require('./server/routes'); |
| 5 | |
| 6 | const app = express(); |
| 7 | app.use(express.json({ limit: '10mb' })); |
| 8 | app.use('/api', apiRouter); |
| 9 | |
| 10 | app.use(express.static(require('path').join(__dirname, 'public'))); |
| 11 | |
| 12 | const server = http.createServer(app); |
| 13 | setupWebSocket(server); |
| 14 | |
| 15 | const PORT = process.env.PORT || 3045; |
| 16 | |
| 17 | server.listen(PORT, () => { |
| 18 | console.log(`Server listening on http://localhost:${PORT}`); |
| 19 | }); |