mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 11:39:36 +02:00
Split apps controllers into separate files
This commit is contained in:
parent
b7de1e3d27
commit
34279c8b8c
16 changed files with 444 additions and 398 deletions
27
controllers/apps/getSingleApp.js
Normal file
27
controllers/apps/getSingleApp.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
const asyncWrapper = require('../../middleware/asyncWrapper');
|
||||
const App = require('../../models/App');
|
||||
|
||||
// @desc Get single app
|
||||
// @route GET /api/apps/:id
|
||||
// @access Public
|
||||
const getSingleApp = asyncWrapper(async (req, res, next) => {
|
||||
const app = await App.findOne({
|
||||
where: { id: req.params.id },
|
||||
});
|
||||
|
||||
if (!app) {
|
||||
return next(
|
||||
new ErrorResponse(
|
||||
`App with the id of ${req.params.id} was not found`,
|
||||
404
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: app,
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = getSingleApp;
|
Loading…
Add table
Add a link
Reference in a new issue