我有以下接受 GET 和 POST 数据的快速 POST 路由处理程序,如下所示:
app.post('/handler/:id/:type', function (req, res, next) {
var id = req.param('id');
var type = req.param('type');
var body = req.body;
// Ho to check req.body params?
var document = _.extend(req.body, {id: id, type: type});
Collection.create(document, function (err, data) {
.....
})
});
如上例所示,不检查传入参数并写入 MongoDB 数据库是否有问题?或者如何检查这些?