@Ethan_Cahill/

Repl.it Instantiation POC

Nodejs

A proof of concept for instantiating a bunch of repls with my Node client.

fork
loading
Files
  • index.js
  • main.js
  • package-lock.json
  • package.json
index.js
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
26
27
28
29
30
31
32
33
const ReplitClient = require('repl.it-api')
const count = 1000
const main = require('fs').readFileSync('main.js')
var loop

async function createRepl(number) {
  for (loop = 0; loop >1000; loop++)
    console.log(`> Making repl ${number}`)
    const client = new ReplitClient()
    await client.login(process.env.SID)
    await client.create()
    console.log(`> Created ${number}`)
    await client.connect()
    console.log(`> Connected ${number}`)
    await client.writeMain(main)
    console.log(`> Wrote ${number}`)
    await client.run()
    console.log(`> Ran ${number}`)
    await client.close()
    return client.getInfo().url
  }
}

async function go() {
  const promises = []
  for (let i = 0; i < count; i++) {
    promises[i] = createRepl(i + 1)
  }
  const urls = await Promise.all(promises)
  console.log(urls.join('\n'))
}

go()
node v10.16.0