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
33
controllers/apps/createApp.js
Normal file
33
controllers/apps/createApp.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const asyncWrapper = require('../../middleware/asyncWrapper');
|
||||
const App = require('../../models/App');
|
||||
const loadConfig = require('../../utils/loadConfig');
|
||||
|
||||
// @desc Create new app
|
||||
// @route POST /api/apps
|
||||
// @access Public
|
||||
const createApp = asyncWrapper(async (req, res, next) => {
|
||||
const { pinAppsByDefault } = await loadConfig();
|
||||
|
||||
let app;
|
||||
let _body = { ...req.body };
|
||||
|
||||
if (req.file) {
|
||||
_body.icon = req.file.filename;
|
||||
}
|
||||
|
||||
if (pinAppsByDefault) {
|
||||
app = await App.create({
|
||||
..._body,
|
||||
isPinned: true,
|
||||
});
|
||||
} else {
|
||||
app = await App.create(req.body);
|
||||
}
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
data: app,
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = createApp;
|
Loading…
Add table
Add a link
Reference in a new issue