ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

47 lines
1.2 KiB

  1. const fs = require('fs')
  2. const path = require('path')
  3. async function register ({
  4. storageManager,
  5. peertubeHelpers,
  6. getRouter
  7. }) {
  8. const { logger } = peertubeHelpers
  9. {
  10. await storageManager.storeData('superkey', { value: 'toto' })
  11. await storageManager.storeData('anotherkey', { value: 'toto2' })
  12. await storageManager.storeData('storedArrayKey', ['toto', 'toto2'])
  13. const result = await storageManager.getData('superkey')
  14. logger.info('superkey stored value is %s', result.value)
  15. const storedArrayValue = await storageManager.getData('storedArrayKey')
  16. logger.info('storedArrayKey isArray is %s', Array.isArray(storedArrayValue) ? 'true' : 'false')
  17. logger.info('storedArrayKey stored value is %s', storedArrayValue.join(', '))
  18. }
  19. {
  20. getRouter().get('/create-file', async (req, res) => {
  21. const basePath = peertubeHelpers.plugin.getDataDirectoryPath()
  22. fs.writeFile(path.join(basePath, 'Aladdin.txt'), 'Prince Ali', function (err) {
  23. if (err) return res.sendStatus(500)
  24. res.sendStatus(200)
  25. })
  26. })
  27. }
  28. }
  29. async function unregister () {
  30. return
  31. }
  32. module.exports = {
  33. register,
  34. unregister
  35. }
  36. // ###########################################################################