getSingleApp.js 574 B

123456789101112131415161718192021222324252627
  1. const asyncWrapper = require('../../middleware/asyncWrapper');
  2. const App = require('../../models/App');
  3. // @desc Get single app
  4. // @route GET /api/apps/:id
  5. // @access Public
  6. const getSingleApp = asyncWrapper(async (req, res, next) => {
  7. const app = await App.findOne({
  8. where: { id: req.params.id },
  9. });
  10. if (!app) {
  11. return next(
  12. new ErrorResponse(
  13. `App with the id of ${req.params.id} was not found`,
  14. 404
  15. )
  16. );
  17. }
  18. res.status(200).json({
  19. success: true,
  20. data: app,
  21. });
  22. });
  23. module.exports = getSingleApp;