about summary refs log tree commit diff
path: root/scripts/testing-server.mjs
blob: adc214cf9299e0576f4934296b7849468d5687f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {IpldStore} from '@adxp/common'
import PDSServer from '@adxp/server/dist/server.js'
import PDSDatabase from '@adxp/server/dist/db/index.js'
import WSRelayServer from '@adxp/ws-relay/dist/index.js'

const PDS_PORT = 2583
const WSR_PORT = 3005

async function start() {
  console.log('Initializing...')

  const db = PDSDatabase.memory()
  const serverBlockstore = IpldStore.createInMemory()
  await db.dropTables()
  await db.createTables()
  PDSServer(serverBlockstore, db, PDS_PORT)

  if (process.argv.includes('--relay')) {
    WSRelayServer(WSR_PORT)
    console.log(`🔁 Relay server running on port ${WSR_PORT}`)
  } else {
    console.log('Include --relay to start the WS Relay')
  }
}
start()