2021-04-22 04:55:28 -04:00
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
|
|
|
|
2020-05-04 03:44:00 -04:00
|
|
|
async function register ({
|
|
|
|
storageManager,
|
2021-04-22 04:55:28 -04:00
|
|
|
peertubeHelpers,
|
|
|
|
getRouter
|
2020-05-04 03:44:00 -04:00
|
|
|
}) {
|
|
|
|
const { logger } = peertubeHelpers
|
|
|
|
|
|
|
|
{
|
|
|
|
await storageManager.storeData('superkey', { value: 'toto' })
|
|
|
|
await storageManager.storeData('anotherkey', { value: 'toto2' })
|
2021-12-15 03:35:17 -05:00
|
|
|
await storageManager.storeData('storedArrayKey', ['toto', 'toto2'])
|
2020-05-04 03:44:00 -04:00
|
|
|
|
|
|
|
const result = await storageManager.getData('superkey')
|
|
|
|
logger.info('superkey stored value is %s', result.value)
|
2021-12-15 03:35:17 -05:00
|
|
|
|
|
|
|
const storedArrayValue = await storageManager.getData('storedArrayKey')
|
2021-12-16 04:15:27 -05:00
|
|
|
logger.info('storedArrayKey isArray is %s', Array.isArray(storedArrayValue) ? 'true' : 'false')
|
2021-12-15 03:35:17 -05:00
|
|
|
logger.info('storedArrayKey stored value is %s', storedArrayValue.join(', '))
|
2020-05-04 03:44:00 -04:00
|
|
|
}
|
2021-04-22 04:55:28 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2020-05-04 03:44:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function unregister () {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
register,
|
|
|
|
unregister
|
|
|
|
}
|
|
|
|
|
|
|
|
// ###########################################################################
|