getImage.js 752 B

1234567891011121314151617181920212223242526272829
  1. 'use strict'
  2. import express from 'express'
  3. import { promises } from 'fs'
  4. import { imagesPath } from '../../config'
  5. const fs = promises
  6. const router = express.Router()
  7. router.get('/', async (req, res) => {
  8. const requiredParameters = ['sceneName', 'imageQuality']
  9. const params = req.query
  10. // Check if all required parameters were passed
  11. if (!requiredParameters.every(parameter => Object.keys(params).includes(parameter))) {
  12. // Some parameters are missing
  13. res.statusCode = 400
  14. res.json({ error: `Missing parameter(s). Required parameters : ${requiredParameters.join(', ')}.` })
  15. return
  16. }
  17. const dirContent = await fs.readdir(imagesPath)
  18. res.json(req.query)
  19. res.json({ msg: 'Not ready yet' })
  20. })
  21. export default router