Book Image

The Node Craftsman Book

By : Manuel Kiessling
Book Image

The Node Craftsman Book

By: Manuel Kiessling

Overview of this book

The Node Craftsman Book helps JavaScript programmers with basic Node.js knowledge to now thoroughly master Node.js and JavaScript. This book dives you deeper into the craft of software development with Node.js and JavaScript, incuding object-orientation, test-driven development, database handling, web frameworks, and much more. The Node Craftsman Book shows you how to work with Node.js and how to think deeply about how you build your Node projects. You'll master how to build a complete Node.js application across six crafting milestones, and you'll learn many specific skills to achieve that mastery. These skills include how to work with the Node Package Manager in depth, how to connect your Node applications to databases, and how to write unit tests and end-to-end tests for your code. You'll experience the full Node.js development picture, and learn how to craft and control your Node.js applications - right through to fully-fledged web applications using REST, and integration with Angular applications.
Table of Contents (17 chapters)
Free Chapter
1
Part 1: Node.js Basics in Detail
2
Working with NPM and Packages
3
Test-driven Node.js Development
11
Milestone 1 – A First Passing Test Against the Server
13
Milestone 3 – Setting the Stage for a Continuous Delivery Workflow

Applying CRUD operations with the low-level mongodb driver

Again, I won't cover installation of the server software. Please refer to the official installation instructions(h t t p s ://d o c s . m o n g o d b . c o m /m a n u a l /i n s t a l l a t i o n /) in order to get a MongoDB server up and running on your machine.

If you have Docker installed on your machine, the quickest way to get a MongoDB server up and running is this one-liner:

docker run --rm --name mongo -p 27017:27017 -d mongo:3.4

See h t t p s ://h u b . d o c k e r . c o m /_ /m o n g o / for more details.

Once this is done, create a new project folder called mongodb-test, and in there create an initial package.json as follows:

{ 
   "name": "mongodb-test", 
   "version": "0.0.1",
   "description": "", 
   "dependencies": { 
     "mongodb": "^2.2.22&quot...