mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-27 23:09:35 +02:00
Merge branch 'master' of https://github.com/pawelmalak/flame into merge_upstream_2020-12-06
This commit is contained in:
commit
021bd4e85a
266 changed files with 13470 additions and 7067 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 body = { ...req.body };
|
||||
|
||||
if (body.icon) {
|
||||
body.icon = body.icon.trim();
|
||||
}
|
||||
|
||||
if (req.file) {
|
||||
body.icon = req.file.filename;
|
||||
}
|
||||
|
||||
const app = await App.create({
|
||||
...body,
|
||||
categoryId: parseInt(req.body.categoryId),
|
||||
isPinned: pinAppsByDefault,
|
||||
});
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
data: app,
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = createApp;
|
Loading…
Add table
Add a link
Reference in a new issue