-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
542 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const express = require('express') | ||
const app = express() | ||
const port = 3000 | ||
const RecordManager = require('./recordManager') | ||
const bodyParser = require('body-parser') | ||
|
||
app.use(bodyParser.json()); | ||
|
||
app.post('/recorder/v1/start', (req, res, next) => { | ||
let { body } = req; | ||
let { appid, channel, key, uid } = body; | ||
if (!appid) { | ||
throw new Error("appid is mandatory"); | ||
} | ||
if (!channel) { | ||
throw new Error("channel is mandatory"); | ||
} | ||
|
||
RecordManager.start(key, appid, channel, uid).then(recorder => { | ||
//start recorder success | ||
res.status(200).json({ | ||
success: true, | ||
sid: recorder.sid | ||
}); | ||
}).catch((e) => { | ||
//start recorder failed | ||
next(e); | ||
}); | ||
}) | ||
|
||
app.post('/recorder/v1/stop', (req, res, next) => { | ||
let { body } = req; | ||
let { sid } = body; | ||
if (!sid) { | ||
throw new Error("sid is mandatory"); | ||
} | ||
|
||
RecordManager.stop(sid); | ||
res.status(200).json({ | ||
success: true | ||
}); | ||
}) | ||
|
||
app.use( (err, req, res, next) => { | ||
console.error(err.stack) | ||
res.status(500).json({ | ||
success: false, | ||
err: err.message || 'generic error' | ||
}) | ||
}) | ||
|
||
app.listen(port) |
Oops, something went wrong.