Update server/src/index.js
This commit is contained in:
@@ -6,6 +6,8 @@ import cookieParser from 'cookie-parser';
|
||||
import http from 'http';
|
||||
import { Server as IOServer } from 'socket.io';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
import { init as dbInit, Characters, Inventory, query } from './db.js';
|
||||
|
||||
@@ -94,8 +96,11 @@ app.get('/api/me', async (req, res) => {
|
||||
res.json({ character: ch, inventory: inv, world: WORLD });
|
||||
});
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// Serve client
|
||||
app.use(express.static(new URL('../static', import.meta.url).pathname));
|
||||
app.use(express.static(path.join(__dirname, '../static')));
|
||||
|
||||
const server = http.createServer(app);
|
||||
const io = new IOServer(server, {
|
||||
|
||||
Reference in New Issue
Block a user