galleryController.js 754 B

123456789101112131415161718192021222324252627282930
  1. const config = require('../config.js')
  2. const db = require('knex')(config.database)
  3. let galleryController = {}
  4. galleryController.list = function(req, res, next){
  5. //if(!config.privacy.public)
  6. //if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('Not Authorized!')
  7. db.table('gallery').select('id', 'name').then((data) => {
  8. res.json({ data })
  9. })
  10. }
  11. galleryController.test = function(req, res, next){
  12. if(!config.privacy.public)
  13. if(!config.privacy.IPs.includes(req.ip)) return res.status(401).send('Not Authorized!')
  14. let testdata = [
  15. {name: 'Test 1'},
  16. {name: 'Test 2'},
  17. {name: 'Test 3'},
  18. {name: 'Test 4'},
  19. {name: 'Test 5'}
  20. ]
  21. db.table('gallery').insert(testdata).then(() => {})
  22. }
  23. module.exports = galleryController