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

Writing universal modules


We have already written many of our own modules as part of our application. We can also write library modules for use in other applications.

When writing code for use by others, it's worth considering in what contexts it will be useful. Some libraries are only useful in specific environments. For example, Express is server-specific and jQuery is browser-specific. But many modules provide functionality that would be useful in any environment, for example, utility modules such as the uuid module we've used elsewhere in this book.

Let's look at writing a module to work in multiple environments. We'll need to support more than just Node.js-style modules. We'll also need to support client-side module systems such as RequireJS. Recall from Chapter 4, Introducing Node.js Modules, that Node.js and RequireJS implement two different module standards (CommonJS and Asynchronous Module Definition (AMD), respectively). Our package may also be used client-side in a website with...