Testing RestFull api (MongoDB, Joi validation, Handlebar Template Engine) using Supertest, Mocha and Istanbul
$ npm install
$ npm install --g mocha
$ npm install -g nodemon
$ nodemon
$ sudo service mongod start
$ sudo service mongod stop
$ sudo service mongod restart
$ mongo --host 127.0.0.1:27017
Remove Packages
$ sudo apt-get purge mongodb-org*
Remove Data Directory
$ sudo rm -r /var/log/mongodb
$ sudo rm -r /var/lib/mongodb
Log: /var/log/mongodb/mongod.log
$ sudo service mongod start
$ mongo --host 127.0.0.1:27017
$ show dbs
$ use nodeapp
$ db.createCollection('books')
$ db.createCollection('genres')
$ db.genres.insert({name: 'Test name 1'})
$ db.genres.find().pretty()
$ db.books.insert({title : "Test title 1", genres : "Suspense", description : "This is for test description 1", author : "auther 1"});
$ db.books.find().pretty()
More info: https://docs.mongodb.com/manual/crud/
$ sudo service mongod start
Books:
get: /api/books
get: /api/books/1
post: /api/books
put: /api/books/1
delete: /api/books/1
genres:
get: /api/genres
get: /api/genres/1
post: /api/genres
put: /api/genres/1
delete: /api/genres/1