Creating the route for adding new keywords

Creating a new keyword results in a POST request to /api/keywords. Let's extend our spec accordingly:

For the sake of brevity, I'm only showing the additional it block instead of the whole spec file.
it('should create a new keyword when receiving a POST request at \
 /api/keywords/', function (done) { var expected = { "_items": [ {'id': 1, 'value': 'Aubergine', 'categoryID': 1}, {'id': 2, 'value': 'Onion', 'categoryID': 1} ] }; var body = { 'value': 'Onion', 'categoryID': 1 }; async.series( [ function(callback) { dbSession.insert( 'category', {'name': 'Vegetable'}, function(err) { callback(err) }); }, function(callback) { dbSession.insert( 'keyword', {'value': 'Aubergine', 'categoryID': 1}, function(err) ...

Get The Node Craftsman Book now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.