diff --git a/server/plugins/migrations.ts b/server/plugins/migrations.ts deleted file mode 100644 index 2ee319f..0000000 --- a/server/plugins/migrations.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { consola } from 'consola' -import { migrate } from 'drizzle-orm/d1/migrator' - -export default defineNitroPlugin(async () => { - if (!import.meta.dev) - return - - onHubReady(async () => { - await migrate(useDB(), { migrationsFolder: 'server/database/migrations' }) - .then(() => { - consola.success('Database migrations done') - }) - .catch((err) => { - consola.error('Database migrations failed', err) - }) - }) -}) diff --git a/server/routes/visitors.ts b/server/routes/visitors.ts index 806d953..bd22a39 100644 --- a/server/routes/visitors.ts +++ b/server/routes/visitors.ts @@ -2,17 +2,13 @@ import { getQuery } from 'ufo' export default defineWebSocketHandler({ open(peer) { - // We send the latitude and longitude query params when connecting to the server const locations = Array.from(peer.peers.values()).map(peer => getQuery(peer.websocket.url!)) - // We send the (anonymous) user locations to the server peer.subscribe('visitors') peer.publish('visitors', JSON.stringify(locations)) peer.send(JSON.stringify(locations)) }, close(peer) { peer.unsubscribe('visitors') - // Wait 500ms before sending the updated locations to the server - // This to avoid sending the location of the user that just left setTimeout(() => { const locations = Array.from(peer.peers.values()).map(peer => getQuery(peer.websocket.url!)) peer.publish('visitors', JSON.stringify(locations))