Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
fix: defined dirname (#429)
Browse files Browse the repository at this point in the history
`__dirname` is not available in ESM environments, we have to derive
it from the import meta.
  • Loading branch information
achingbrain authored May 11, 2022
1 parent 6dd3877 commit ced684b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/webrtc-star-signalling-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import Inert from '@hapi/inert'
import { config } from './config.js'
// @ts-expect-error no types
import menoetius from 'menoetius'
import path from 'path'
import path, { dirname } from 'path'
import { socketServer } from './socket-server.js'
import type { WebRTCStarSocket } from '@libp2p/webrtc-star-protocol'
import type { Server as SocketServer } from 'socket.io'
import { fileURLToPath } from 'url'

const currentDir = dirname(fileURLToPath(import.meta.url))

const log = config.log

Expand Down Expand Up @@ -52,7 +55,7 @@ export async function sigServer (options: Options = {}) {
http.route({
method: 'GET',
path: '/',
handler: (request, reply) => reply.file(path.join(__dirname, 'index.html'), {
handler: (request, reply) => reply.file(path.join(currentDir, 'index.html'), {
confine: false
})
})
Expand Down

0 comments on commit ced684b

Please sign in to comment.