Book Image

Learning Node.js for .NET Developers

Book Image

Learning Node.js for .NET Developers

Overview of this book

Node.js is an open source, cross-platform runtime environment that allows you to use JavaScript to develop server-side web applications. This short guide will help you develop applications using JavaScript and Node.js, leverage your existing programming skills from .NET or Java, and make the most of these other platforms through understanding the Node.js programming model. You will learn how to build web applications and APIs in Node, discover packages in the Node.js ecosystem, test and deploy your Node.js code, and more. Finally, you will discover how to integrate Node.js and .NET code.
Table of Contents (21 chapters)
Learning Node.js for .NET Developers
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Index

A

  • adapter pattern / Using Redis as a backend
  • afterEach hook
    • about / Resetting state between tests
  • aggregation pipeline
    • about / Using the MongoDB shell
  • Ajax
    • used, for communication / Communicating via Ajax
  • alternative session stores
    • using / Using alternative session stores
  • AMD
    • about / JavaScript module systems
  • AMD modules
    • using, with RequireJS / Using AMD modules with RequireJS
  • app.js file / Exploring our Express application
  • application
    • executing, locally with Heroku / Running an application locally with Heroku
    • deploying, with Heroku / Deploying an application to Heroku
  • application framework
    • using / Using an application framework
    • Express, using / Getting started with Express
  • array literal notation
    • about / Functional programming in JavaScript
  • asm.js
    • about / Understanding asm.js
    • URL / Understanding asm.js
  • ASP.NET
    • and JavaScript / JavaScript and ASP.NET
    • .NET Core / Exploring .NET Core
    • integration, with JavaScript / Integration with JavaScript
    • server-side JavaScript integration / Server-side JavaScript integration with .NET
  • assembly language
    • about / Introducing a true assembly language for the web
    • asm.js / Understanding asm.js
    • WebAssembly / Understanding WebAssembly
  • assertions
    • writing, with Chai / Using Chai for assertions
  • asynchronous code
    • callback pattern, using / Using the callback pattern for asynchronous code
    • writing, promises used / Writing cleaner asynchronous code using promises
    • promise-based asynchronous code, implementing / Implementing promise-based asynchronous code
    • operations, parallelizing with promises / Parallelising operations using promises
  • asynchronous interfaces
    • consuming / Consuming asynchronous interfaces
  • Asynchronous Module Definition (AMD) / Writing universal modules
  • asynchronous programming
    • about / Non-blocking
  • asynchronous programming patterns
    • combining / Combining asynchronous programming patterns
  • asynchronous tests
    • writing, in Mocha / Testing an Express application
  • Atom
    • URL / Choosing an editor

B

  • BDD-style tests
    • writing, with Mocha / Writing BDD-style tests with Mocha
    • state, resetting / Resetting state between tests
  • beforeEach hook
    • about / Resetting state between tests
  • behavior-driven development (BDD) style
    • about / Writing BDD-style tests with Mocha
  • bin/www file / Exploring our Express application
  • binary JSON (BSON)
    • about / Introducing MongoDB
  • browser
    • Node.js modules, using / Using Node.js modules in the browser
  • Browserify
    • URL / Using Node.js modules in the browser, Controlling Browserify's output
    • output, controlling / Controlling Browserify's output
  • build process
    • automating, with Gulp / Automating the build process with Gulp
    • tests, executing with Gulp / Running tests using Gulp

C

  • callback function
    • about / Non-blocking
  • callback pattern
    • using, asynchronous code / Using the callback pattern for asynchronous code
    • exposing / Exposing the callback pattern
    • asynchronous interfaces, consuming / Consuming asynchronous interfaces
  • Chai
    • used, for assertions / Using Chai for assertions
    • URL / Using Chai for assertions
  • chat room
    • implementing, Socket.IO used / Implementing a chat room with Socket.IO
  • class-based inheritance
    • about / Class-based inheritance
  • classes
    • avoiding, in object-oriented programming / Programming without classes
    • objects, creating with new keyword / Creating objects with the new keyword
    • used, in object-oriented programming / Programming with classes
    • class-based inheritance / Class-based inheritance
  • client-side JavaScript
    • reference link / Integration with JavaScript
  • Clojure
    • URL / And beyond...
  • codebase
    • organizing / Organizing your codebase
    • JavaScript module systems / JavaScript module systems
  • code coverage statistics
    • gathering / Gathering code coverage statistics
  • code style
    • checking, with ESLint / Checking code style with ESLint
  • CoffeeScript
    • about / CoffeeScript
  • collections
    • about / Introducing MongoDB
  • CommonJS
    • about / JavaScript module systems
  • compile-to-JavaScript languages
    • about / Exploring compile-to-JavaScript languages
    • TypeScript / TypeScript
    • CoffeeScript / CoffeeScript
  • connect-owin project
    • URL / Server-side JavaScript integration with .NET
  • const keyword
    • about / Strict mode
  • Continuous Integration (CI)
    • about / Setting up an integration server
  • Cookie Choices
    • URL / Deciding when the session gets saved

D

  • Dart
    • URL / And beyond...
  • database integration tests
    • executing, on Travis CI / Running database integration tests on Travis CI
  • data operations
    • implementing / Implementing other data operations
    • data, listing in views / Listing data in views
    • delete request, issuing from client / Issuing a delete request from the client
    • Express views, splitting up / Splitting up Express views using partials
  • Denial of Service (DoS) attack / Running automated clients on the web
  • dependencies
    • managing, in .NET Core / Managing dependencies in .NET Core
  • dependency injection (DI)
    • in Node.js / Dependency injection in Node.js
  • development dependency
    • about / Writing BDD-style tests with Mocha
  • directory-level module
    • defining / Defining a directory-level module
  • document-oriented DBMS
    • about / Introducing MongoDB
  • Document Object Model (DOM)
    • about / What is Node.js?

E

  • ECMAScript
    • versioning / Understanding ECMAScript versioning
  • ECMAScript 2015
    • exploring / Exploring ECMAScript 2015
    • URL / Exploring ECMAScript 2015
    • ES2015 modules / Understanding ES2015 modules
    • generator functions / Introducing generators
  • ECMAScript 2016
    • about / Introducing ECMAScript 2016
  • Edge.js
    • URL / Server-side JavaScript integration with .NET
  • Edge.js project
    • URL / Server-side JavaScript integration with .NET
  • editor
    • selecting / Choosing an editor
  • encrypted environment variable
    • setting up / Setting encrypted Travis CI environment variables
    • Ruby, installing / Installing Ruby
    • creating / Creating an encrypted environment variable
  • ES2015 modules
    • about / Understanding ES2015 modules
    • URL / Understanding ES2015 modules
    • syntax improvements, using / Using syntax improvements from ES2015
    • for... of loop / The for... of loop
    • spread operator / The spread operator and rest parameters
    • rest parameters / The spread operator and rest parameters
    • assignment, destructuring / Destructuring assignment
  • ESLint
    • code style, checking with / Checking code style with ESLint
    • issues, fixing automatically / Automatically fixing issues in ESLint
    • URL, for rules / Automatically fixing issues in ESLint
    • executing, from Gulp / Running ESLint from Gulp
  • event-driven execution model
    • about / Event-driven
  • event loop
    • about / Event-driven
  • execution model, Node.js
    • about / Understanding the Node.js execution model
    • non-blocking / Non-blocking
    • event-driven / Event-driven
    • single-threaded / Single-threaded
  • Express
    • using / Getting started with Express
    • routes / Understanding Express routes and views
    • views / Understanding Express routes and views
    • nodemon, using / Using nodemon for automatic restarts
    • modular applications, creating / Creating modular applications with Express
    • middleware / Understanding Express middleware
    • MongoDB, using with / Using MongoDB with Express
    • Socket.IO, integrating / Integrating Socket.IO with Express
  • Express application
    • exploring / Exploring our Express application
    • bootstrapping / Bootstrapping an Express application
    • testing / Testing an Express application
    • tests, simplifying with SuperAgent / Simplifying tests using SuperAgent
  • Express application, folders
    • node_modules / Exploring our Express application
    • public / Exploring our Express application
    • routes / Exploring our Express application
    • views / Exploring our Express application
  • Express middleware module
    • implementing / Implementing an Express middleware module
  • Express sessions
    • using / Using Express sessions
    • session secret, specifying / Specifying a session secret
    • session, saving / Deciding when the session gets saved
    • alternative session stores, using / Using alternative session stores
    • session middleware, using / Using session middleware
  • Express views
    • splitting up, with partials / Splitting up Express views using partials

F

  • Facebook application
    • URL / Adding other login providers
  • for... of loop
    • about / The for... of loop
  • full-stack testing
    • with PhantomJS / Full-stack testing with PhantomJS
  • functional object-oriented programming
    • about / Functional object-oriented programming
    • JavaScript / Functional programming in JavaScript
    • object-oriented programming / Object-oriented programming in JavaScript

G

  • Gem
    • about / Creating an encrypted environment variable
  • generator functions
    • about / Introducing generators
    • reference link / Introducing generators
  • GitHub
    • URL / Setting up a public GitHub repository, Building a project on Travis CI
  • governance model
    • URL / A brief history of Node.js
  • Gulp
    • build process, automating / Automating the build process with Gulp
    • tests, executing / Running tests using Gulp
    • ESLint, executing from / Running ESLint from Gulp
    • integration tests, executing / Running integration tests from Gulp

H

  • Hangman
    • URL / Handling user-submitted data
    • user-submitted data, handling / Handling user-submitted data
    • communicating, via Ajax / Communicating via Ajax
    • data operations, implementing / Implementing other data operations
  • hashes
    • about / Storing structured data in Redis
  • Heroku
    • about / Working with Heroku
    • URL / Working with Heroku
    • account, setting up / Setting up a Heroku account and tooling
    • application, executing / Running an application locally with Heroku
    • application, deploying / Deploying an application to Heroku
    • MongoDB, setting up / Setting up MongoDB
    • Redis, setting up / Setting up Redis
  • Heroku config
    • working with / Working with Heroku logs, config, and services
  • Heroku logs
    • working with / Working with Heroku logs, config, and services
  • Heroku services
    • working with / Working with Heroku logs, config, and services
  • heroku toolbelt
    • URL / Setting up a Heroku account and tooling
  • higher-order functions
    • about / Functional programming in JavaScript

I

  • Immediately-Invoked Function Expression (IIFE) / Supporting the browser environment
  • integration server
    • about / Setting up an integration server
    • setting up / Setting up an integration server
    • public GitHub repository, setting up / Setting up a public GitHub repository
    • project, building on Travis CI / Building a project on Travis CI
  • integration tests
    • executing, from Gulp / Running integration tests from Gulp
  • io.js
    • about / A brief history of Node.js
  • Isomorphic JavaScript
    • URL / Isomorphic JavaScript

J

  • Jasmine
    • about / Writing BDD-style tests with Mocha
  • JavaScript
    • about / Why JavaScript?, JavaScript
    • canvas / A clear canvas
    • functions / Functional nature
    • future / A bright future
    • functional programming / Functional programming in JavaScript
    • scopes / Understanding scopes in JavaScript
    • object-oriented programming / Object-oriented programming in JavaScript
    • exploring / Going beyond JavaScript
    • reference link / Going beyond JavaScript
    • compile-to-JavaScript languages / Exploring compile-to-JavaScript languages
    • assembly language / Introducing a true assembly language for the web
    • and ASP.NET / JavaScript and ASP.NET
    • ASP.NET integration / Integration with JavaScript
  • JavaScript module systems
    • about / JavaScript module systems
  • JavaScript primitive types
    • about / JavaScript primitive types
  • JavaScript types
    • about / Introducing JavaScript types
    • primitive types / JavaScript primitive types

K

  • key-value data store
    • about / Introducing Redis

L

  • Language-Integrated Query (LINQ)
    • about / Functional programming in JavaScript
  • let keyword
    • about / Strict mode
  • lists
    • about / Storing structured data in Redis
  • login providers
    • adding / Adding other login providers
  • long-polling / Understanding options for real-time communication
  • long-term support (LTS)
    • about / Introducing the Node.js LTS schedule
  • LTS schedule
    • about / Introducing the Node.js LTS schedule
    • URL / Introducing the Node.js LTS schedule

M

  • Map-Reduce
    • about / Using the MongoDB shell
    • URL / Using the MongoDB shell
  • middleware
    • about / Building web applications in ASP.NET Core
    • URL / Building web applications in ASP.NET Core
  • middleware, Express
    • about / Understanding Express middleware
    • error handling, implementing / Implementing error handling
    • using / Using Express middleware
  • Mocha
    • BDD-style tests, writing / Writing BDD-style tests with Mocha
    • about / Writing BDD-style tests with Mocha
    • asynchronous tests, writing / Testing an Express application
  • Mockgoose
    • about / Providing dependencies
  • mocks
    • about / Creating test doubles using Sinon.JS
  • model
    • about / Persisting objects with Mongoose
  • modular applications
    • creating, with Express / Creating modular applications with Express
  • module counts
    • reference link / Introducing the Node.js ecosystem
  • modules
    • about / Organizing your codebase
    • creating / Creating modules in Node.js
    • declaring, with name / Declaring a module with a name and its own scope
    • declaring, with scope / Declaring a module with a name and its own scope
    • functionality, defining / Defining functionality provided by the module
    • importing, into another script / Importing a module into another script
    • directory-level module, defining / Defining a directory-level module
    • Express middleware module, implementing / Implementing an Express middleware module
  • Modulus
    • URL / Further resources
  • MongoDB
    • about / Introducing MongoDB
    • advantages / Why choose MongoDB?
    • object modelling / Object modeling
    • JavaScript / JavaScript
    • scalability / Scalability
    • URL / Getting started with MongoDB
    • URL, for installation / Getting started with MongoDB
    • directory, creating / Getting started with MongoDB
    • shell, using / Using the MongoDB shell
    • URL, for documentation / Using the MongoDB shell
    • using, with Express / Using MongoDB with Express
    • objects, persisting with Mongoose / Persisting objects with Mongoose
    • persistence code, isolating / Isolating persistence code
    • dependency injection (DI), in Node.js / Dependency injection in Node.js
    • dependencies, providing / Providing dependencies
    • database integration tests, executing / Running database integration tests on Travis CI
    • setting up / Setting up MongoDB
  • Mongoose
    • about / Using MongoDB with Express
    • objects, persisting / Persisting objects with Mongoose
  • Mustache
    • URL / Understanding Express routes and views

N

  • .NET Core
    • about / Exploring .NET Core
    • project structure, defining / Defining project structure in .NET Core
    • dependencies, managing / Managing dependencies in .NET Core
    • web applications, building / Building web applications in ASP.NET Core
  • N4JS
    • URL / TypeScript
  • namespaces
    • used, for organizing Socket.IO applications / Organizing Socket.IO applications using namespaces
  • new keyword
    • used, for creating objects / Creating objects with the new keyword
  • Node.js
    • about / What is Node.js?
    • ecosystem / Introducing the Node.js ecosystem
    • usage / When to use Node.js
    • web applications, writing / Writing web applications
    • use cases / Identifying other use cases
    • need for / Why now?
    • URL / Installing and running Node.js
    • installing / Installing and running Node.js
    • running / Installing and running Node.js
    • dependency injection (DI) / Dependency injection in Node.js
    • Redis, using / Using Redis from Node.js
    • and RequireJS, comparing / Comparing Node.js and RequireJS
    • versioning / Understanding Node.js versioning
    • history / A brief history of Node.js
    • LTS schedule / Introducing the Node.js LTS schedule
  • Node.js modules
    • using, in browser / Using Node.js modules in the browser
    • Browserify output, controlling / Controlling Browserify's output
  • nodemon
    • using / Using nodemon for automatic restarts
  • non-blocking execution model
    • about / Non-blocking
  • npm
    • about / Introducing the Node.js ecosystem
    • package, publishing / Publishing a package to npm
  • npm command line tool
    • about / Introducing the Node.js ecosystem
  • npm packages
    • writing / Writing npm packages
    • defining / Defining an npm package
    • standalone tool, releasing / Releasing a standalone tool to npm
  • npm registry
    • about / Introducing the Node.js ecosystem
  • NuGet package manager
    • about / Managing dependencies in .NET Core
  • Null type
    • about / JavaScript primitive types
  • number
    • about / JavaScript primitive types

O

  • object
    • about / Object-oriented programming in JavaScript
  • object-oriented (OO)
    • about / Why JavaScript?
  • object-oriented programming
    • in JavaScript / Object-oriented programming in JavaScript
    • without classes / Programming without classes
    • with classes / Programming with classes
  • Object-Relational Mapper (ORM)
    • about / Object modeling
  • object modelling
    • about / Object modeling
  • objects
    • creating, with new keyword / Creating objects with the new keyword
  • OmniSharp project
    • URL / Defining project structure in .NET Core
  • OpenID Connect
    • URL / Adding other login providers
  • OWIN
    • about / Building web applications in ASP.NET Core
    • URL / Building web applications in ASP.NET Core

P

  • package
    • publishing, to npm / Publishing a package to npm
    • automated clients, running on web / Running automated clients on the web
    • standalone tool, releasing to npm / Releasing a standalone tool to npm
  • package.json file / Exploring our Express application
  • Passport
    • about / Introducing Passport
    • authentication strategy, selecting / Choosing an authentication strategy
    • third-party authentication / Understanding third-party authentication
    • configuring / Configuring Passport
    • configuring, with persistence / Configuring Passport with persistence
    • integration testing / Integration testing with Passport
  • PhantomJS
    • full-stack testing / Full-stack testing with PhantomJS
    • about / Full-stack testing with PhantomJS
  • pipeline stages
    • about / Using the MongoDB shell
  • Platform-as-a-Service (PaaS) / Further resources
  • Procfile
    • about / Running an application locally with Heroku
  • promise-based asynchronous code
    • implementing / Implementing promise-based asynchronous code
    • consuming / Consuming the promise pattern
  • Promise.coroutine method
    • URL / Introducing generators
  • promises
    • used, for writing asynchronous code / Writing cleaner asynchronous code using promises
    • about / Writing cleaner asynchronous code using promises
    • pending states / Writing cleaner asynchronous code using promises
    • fulfilled states / Writing cleaner asynchronous code using promises
    • rejected states / Writing cleaner asynchronous code using promises
    • used, for parallelizing operations / Parallelising operations using promises
  • Promises/A+
    • URL / Combining asynchronous programming patterns
  • prototypal inheritance
    • about / Programming without classes
  • prototype
    • about / Programming without classes
  • public GitHub repository
    • setting up / Setting up a public GitHub repository

R

  • Read-Eval-Print Loop (REPL)
    • about / What is Node.js?
  • real-time communication
    • options / Understanding options for real-time communication
  • real-time Node.js applications
    • scaling / Scaling real-time Node.js applications
    • Redis, using as backend / Using Redis as a backend
  • Redis
    • about / Introducing Redis
    • advantages / Why use Redis?
    • installing / Installing Redis
    • URL / Installing Redis
    • used, as key-value store / Using Redis as a key-value store
    • structured data, storing / Storing structured data in Redis
    • lists / Storing structured data in Redis
    • hashes / Storing structured data in Redis
    • sets / Storing structured data in Redis
    • sorted sets / Storing structured data in Redis
    • user ranking system, building / Building a user ranking system with Redis
    • using, from Node.js / Using Redis from Node.js
    • setting up / Setting up Redis
    • user data, persisting / Persisting user data with Redis
  • redis-js
    • used, for testing / Testing with redis-js
  • relational property
    • about / Introducing MongoDB
  • RequireJS
    • and Node.js, comparing / Comparing Node.js and RequireJS
  • rest parameters
    • about / The spread operator and rest parameters
  • robots.txt file
    • URL / Running automated clients on the web
  • rooms
    • used, for partitioning Socket.IO clients / Partitioning Socket.IO clients using rooms
  • routes, Express
    • about / Understanding Express routes and views
  • Ruby
    • installing / Installing Ruby
    • URL / Installing Ruby
  • RubyInstaller
    • URL / Installing Ruby

S

  • schema
    • about / Persisting objects with Mongoose
  • scopes, JavaScript
    • about / Understanding scopes in JavaScript
    • global / Understanding scopes in JavaScript
    • functional / Understanding scopes in JavaScript
    • strict mode / Strict mode
  • security
    • about / A note on security
    • references / A note on security
  • Semantic Versioning 2.0.0
    • URL / A brief history of Node.js
  • server-side JavaScript integration
    • about / Server-side JavaScript integration with .NET
  • session middleware
    • using / Using session middleware
  • sets
    • about / Storing structured data in Redis
  • single-threaded execution model
    • about / Single-threaded
  • Sinon.JS
    • used, for creating test doubles / Creating test doubles using Sinon.JS
    • URL / Creating test doubles using Sinon.JS
  • social login
    • implementing / Implementing social login
    • Twitter application, setting up / Setting up a Twitter application
    • Passport, configuring / Configuring Passport
    • user data, persisting with Redis / Persisting user data with Redis
    • Passport, configuring with persistence / Configuring Passport with persistence
    • functionality, hiding from unauthenticated users / Hiding functionality from unauthenticated users
    • integration testing, with Passport / Integration testing with Passport
  • Socket.IO
    • about / Introducing Socket.IO
    • chat room, implementing / Implementing a chat room with Socket.IO
    • integrating, with Express / Integrating Socket.IO with Express
    • messages, directing / Directing Socket.IO messages
    • applications, testing / Testing Socket.IO applications
  • Socket.IO applications, organizing
    • about / Organizing Socket.IO applications
    • real-time updates, exposing to model / Exposing real-time updates to the model
    • namespaces used / Organizing Socket.IO applications using namespaces
    • Socket.IO clients partitioning, rooms used / Partitioning Socket.IO clients using rooms
  • sorted sets
    • about / Storing structured data in Redis
  • spies
    • about / Creating test doubles using Sinon.JS
  • spread operator
    • about / The spread operator and rest parameters
  • spy
    • about / Creating test doubles
  • strict mock
    • about / Creating test doubles using Sinon.JS
  • strict mode
    • about / Strict mode
  • strings
    • about / JavaScript primitive types
  • Strings
    • about / Using Redis as a key-value store
  • stubs
    • about / Creating test doubles using Sinon.JS
  • SuperAgent
    • tests, simplifying with / Simplifying tests using SuperAgent
    • URL / Simplifying tests using SuperAgent
  • SuperTest
    • URL / Simplifying tests using SuperAgent

T

  • table of contents (ToC) / Writing npm packages
  • templating engines
    • about / Getting started with Express
  • test doubles
    • creating / Creating test doubles
    • about / Creating test doubles
    • creating, Sinon.JS used / Creating test doubles using Sinon.JS
  • tests
    • writing / Writing a simple test in Node.js
    • codebase, structuring / Structuring the codebase for tests
    • simplifying, with SuperAgent / Simplifying tests using SuperAgent
  • Travis CI
    • URL / Setting up an integration server, Building a project on Travis CI
    • using / Setting up an integration server
    • project, building / Building a project on Travis CI
    • database integration tests, executing / Running database integration tests on Travis CI
    • used, for deploying / Deploying from Travis CI
    • encrypted environment variable, setting up / Setting encrypted Travis CI environment variables
  • Twelve-Factor App
    • URL / Further resources
  • Twitter
    • URL / Setting up a Twitter application
  • Twitter application
    • setting up / Setting up a Twitter application
  • type definitions
    • reference link / TypeScript
  • TypeScript
    • about / TypeScript
    • URL / TypeScript

U

  • Undefined type
    • about / JavaScript primitive types
  • universal modules
    • writing / Writing universal modules
    • Node.js and RequireJS, comparing / Comparing Node.js and RequireJS
    • browser environment, supporting / Supporting the browser environment
    • AMD modules, using with RequireJS / Using AMD modules with RequireJS
    • isomorphic JavaScript / Isomorphic JavaScript
  • user-submitted data
    • handling / Handling user-submitted data
  • user ranking system
    • building, with Redis / Building a user ranking system with Redis
    • user rankings, implementing / Implementing user rankings with Redis
    • users service, using / Making use of the users service
  • users
    • allowing, to log out / Allowing users to log out

V

  • variable hoisting
    • about / Understanding scopes in JavaScript
  • verify callback
    • about / Configuring Passport
  • views, Express
    • about / Understanding Express routes and views
  • Visual Studio Code
    • URL / Choosing an editor

W

  • web applications
    • writing, with Node.js / Writing web applications
    • building, in .NET Core / Building web applications in ASP.NET Core
  • WebAssembly
    • URL / Understanding WebAssembly
    • about / Understanding WebAssembly
  • Wercker
    • URL / Further resources