forked from external-repos/noisedash
Add profile import and export
This commit is contained in:
@@ -77,6 +77,66 @@ router.post('/profiles', (req, res) => {
|
||||
})
|
||||
})
|
||||
|
||||
router.post('/profiles/import', (req, res) => {
|
||||
if (!req.user) {
|
||||
return res.sendStatus(401)
|
||||
}
|
||||
|
||||
let profileID = 0
|
||||
|
||||
db.serialize(() => {
|
||||
db.run(`INSERT INTO profiles (
|
||||
name,
|
||||
user,
|
||||
timer_enabled,
|
||||
duration,
|
||||
volume,
|
||||
noise_color,
|
||||
filter_enabled,
|
||||
filter_type,
|
||||
filter_cutoff,
|
||||
lfo_filter_cutoff_enabled,
|
||||
lfo_filter_cutoff_frequency,
|
||||
lfo_filter_cutoff_low,
|
||||
lfo_filter_cutoff_high,
|
||||
tremolo_enabled,
|
||||
tremolo_frequency,
|
||||
tremolo_depth)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
||||
req.body.name,
|
||||
req.user.id,
|
||||
req.body.isTimerEnabled ? 1 : 0,
|
||||
req.body.duration,
|
||||
req.body.volume,
|
||||
req.body.noiseColor,
|
||||
req.body.isFilterEnabled ? 1 : 0,
|
||||
req.body.filterType,
|
||||
req.body.filterCutoff,
|
||||
req.body.isLFOFilterCutoffEnabled ? 1 : 0,
|
||||
req.body.lfoFilterCutoffFrequency,
|
||||
req.body.lfoFilterCutoffLow,
|
||||
req.body.lfoFilterCutoffHigh,
|
||||
req.body.isTremoloEnabled ? 1 : 0,
|
||||
req.body.tremoloFrequency,
|
||||
req.body.tremoloDepth
|
||||
],
|
||||
function (err) {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
if (err.code === 'SQLITE_CONSTRAINT') {
|
||||
return res.sendStatus(409)
|
||||
} else {
|
||||
return res.sendStatus(500)
|
||||
}
|
||||
}
|
||||
|
||||
profileID = this.lastID
|
||||
|
||||
return res.json({ id: profileID })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
router.put('/profiles/:profileId', (req, res) => {
|
||||
if (!req.user) {
|
||||
return res.sendStatus(401)
|
||||
|
||||
Reference in New Issue
Block a user