Skip to content

Commit

Permalink
feat: Create inputAudio controller
Browse files Browse the repository at this point in the history
see: #10
  • Loading branch information
sujinleeme committed Jul 1, 2018
1 parent 373dd1b commit 84d1784
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions server/controller/inputAudio.ctrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const InputAudio = require("./../models/InputAudio")
const User = require("./../models/User")
const fs = require("fs")

module.exports = {
addInputAudio: (req, res, next) => {
let {text} = req.body
// check audio files
// if files.audio
// upload
// else
saveInputAudio({title})

const saveInputAudio = (obj) => {
new InputAudio(obj).save((err, audio) => {
if (err)
res.send(err)
else if (!audio)
res.send(400)
else {
return InputAudio.addAuthor(req.body.author_id).then(_audio =>
res.send(_audio)
)
}
next()
})
}
},

getAll: (req, res, next) => {
InputAudio.find(req.params.id)
.populate("author")
},

/**
* audio_id
*/
getInputAudio: (req, res, next) => {
InputAudio.findById(req.params.id)
.populate("author")
}
}

0 comments on commit 84d1784

Please sign in to comment.