aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/fixtures/peertube-plugin-test-six/main.js
blob: 858bdb2df1ba64189950506e3e8eb3ea3bff4d6b (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const fs = require('fs')
const path = require('path')

async function register ({
  storageManager,
  peertubeHelpers,
  getRouter
}) {
  const { logger } = peertubeHelpers

  {
    await storageManager.storeData('superkey', { value: 'toto' })
    await storageManager.storeData('anotherkey', { value: 'toto2' })

    const result = await storageManager.getData('superkey')
    logger.info('superkey stored value is %s', result.value)
  }

  {
    getRouter().get('/create-file', async (req, res) => {
      const basePath = peertubeHelpers.plugin.getDataDirectoryPath()

      fs.writeFile(path.join(basePath, 'Aladdin.txt'), 'Prince Ali', function (err) {
        if (err) return res.sendStatus(500)

        res.sendStatus(200)
      })
    })
  }
}

async function unregister () {
  return
}

module.exports = {
  register,
  unregister
}

// ###########################################################################