Category

node.js

One-Time Passwords (OTP)

By | .NET, node.js | No Comments

Years ago, I worked for a customer who provided me with a RSA SecurID device to access their VPN. This was a plastic fob that would display a six digit number on a LCD screen. Every 30 seconds, the numbers changed to a different random six digits. To log into their VPN, I had to provide my username and password, plus the current six digit number displayed on the device. So, even if my password was compromised, an attacker still could not get into their VPN without also having that SecurID device. Today, we simply call this Two-Factor Authentication, or 2FA. While plastic fobs…

Read More

Angular.js: Configuration for Two Environments within one Project

By | AngularJS, node.js | No Comments

One of our recent projects is an Angular.js app that uses Node.js/Express as the application server. During development, we create feature branches that are merged into a “develop” branch for integration testing. Then, the we merge the “develop” branch into the “master” branch for production deployment. One issue that we had to solve was how to keep environment-specific config in source control. That is, our Angular app needed to know the URL for its API server, and the API server for development was different than production. The first attempt was to maintain one version of a config file in the “develop” branch, and a different version of that…

Read More

Escaping From Relative Paths in Node.js With DI

By | JavaScript, node.js | No Comments

I’ve written before about one way to escape from relative-path “hell” in Node.js by leveraging the built-in behavior of the require function to look in the node_modules folder starting in the current folder and working upwards until it can’t go any further. This approach has some great benefits and I do like it a lot, except for one major problem: My preferred code editor–Visual Studio Code–automatically omits the contents of node_modules folders from search results by default. I have managed to configure my preferences in the past to exclude only the root node_modules folder while including lower ones, but the…

Read More

Node.js + Express.js Video Walkthrough Part 2

By | JavaScript, node.js | One Comment

This is post 2 of 2 in the series “Node.js + Express.js Video Walkthrough” After my recent series on Node.js culminating in an introduction to Express.js, I wanted to give a tour of what an Express.js project looks like, but I also thought that doing so in written form would result in a lot of copy-pasted code that would obscure the bigger picture of the project strucure. So instead, I thought that maybe a video would be a good way to show things in action! This is the second half of a two-part walkthrough of the structure of a Node.js…

Read More

Node.js + Express.js Video Walkthrough Part 1

By | JavaScript, node.js | No Comments

This is post 1 of 2 in the series “Node.js + Express.js Video Walkthrough” After my recent series on Node.js culminating in an introduction to Express.js, I wanted to give a tour of what an Express.js project looks like, but I also thought that doing so in written form would result in a lot of copy-pasted code that would obscure the bigger picture of the project strucure. So instead, I thought that maybe a video would be a good way to show things in action! This is the first half of a two-part walkthrough of the structure of a Node.js…

Read More

Getting Started with Node.js in Windows – Web Apps With Express

By | JavaScript, node.js | No Comments

This is post 3 of 3 in the series “Getting Started with Node JS” Recap In my first post, I went over the basics of Node.js package management with the NPM CLI. In the second, I went a little deeper and delved into the the basic architectural foundations of a Node.js application. Today, we will take all of these things and apply them to create the skeleton of a web application capable of reading data from request URLs and bodies and responding with HTML templates or JSON formatted data. Choices! If there’s one thing that really differentiates the ecosystem of Microsoft .NET…

Read More

Getting Started with Node.js in Windows – Node Modules

By | JavaScript, node.js | No Comments

This is post 2 of 3 in the series “Getting Started with Node JS” Introduction In the previous post, I gave a quick idea of what Node.js is and then fell down the rabbit hole of the topic of NPM. With all that said and done, you should have a basic working knowledge of how to manage NPM packages, both locally and globally. So now let’s turn to the topic of Node.js programming itself. In the previous post about NPM, I mentioned that NPM uses a file named package.json to keep track of dependencies so others can reinstall packages that your…

Read More

Getting Started with Node.js in Windows – NPM

By | JavaScript, node.js | No Comments

This is post 1 of 3 in the series “Getting Started with Node JS” Introduction I’ve already written a few posts about my own journey to find a good Node.js development environment on Windows: journeying from the familiar environment of Visual Studio, to the opposite end of the spectrum with Sublime Text, and then finally somewhere in the middle with Visual Studio Code, where I have dwelt happily ever since. But in the telling of that journey, I’ve glossed over the meat of getting to know Node.js itself, and so that’s what I’m going to do in this post: share…

Read More

Configure VSCode to run NPM tasks

By | node.js, Visual Studio | No Comments

Did you know that you can configure VSCode to run NPM tasks? It’s in the documentation, but not everyone reads the entire manual before jumping in. After all, that code isn’t going to write itself! The feature isn’t visible in any of the menus, either. They are visible in the command palette (ctrl+shift+p), which I like to make use of as much as possible, and I think that’s where I noticed the feature first. Well, maybe I saw it in the docs; I’m that kind of guy. I read the manuals for games before playing, too. …I know. Configuration is super easy,…

Read More

Escaping From Relative-Path require() in Node.js

By | JavaScript, node.js | No Comments

Introduction As an ASP.NET web developer coming to Node.js, one thing that you will notice quickly is the difference in how you reference code in other files. In .NET, you declare at the top of each file which namespace the enclosed code belongs to, and you can then reference that code from any other file simply by importing the namespace; relative file position is irrelevant. In Node.js, this is not the case; every file is implicitly a module, and other files can only reference and load them with the synchronous require function. The simplest way to use require in your own project…

Read More

Node.js in Visual Studio Code review

By | JavaScript, node.js, Visual Studio | 4 Comments

Over the last two posts, I’ve described my experience searching for the best Node.js development setup for me, an ASP.NET developer working in Windows. First I tried Node.js Tools for Visual Studio but found the experience sluggish and frustrating. Next, I moved to Sublime Text 3 with some plugins and command-line based tools, where I lost a few creature comforts but gained more than enough speed in my day-t0-day operations to compensate. But then one of my peers mentioned Atom, so I thought I’d have to give it a serious look. As you might have guessed from the title of…

Read More

Node.js on Windows with Sublime Text 3

By | node.js | One Comment

I recently posted about my experiences developing Node.js apps with Node Tools for Visual Studio: the good and the painful, and why I decided to try something else. I kept hearing good things about Sublime Text over the years, so I thought this would be a good opportunity to try developing with just a good text editor and an ecosystem of command-line tools. Over the course of the first few days, I organically added plugins and utilities as needed to make my development life as comfortable as I could. This is the setup I ended up with: Editor and plugins…

Read More

Node.js Tools for Visual Studio (NTVS) review

By | JavaScript, News, node.js, Visual Studio | No Comments

Here at Falafel, we started out as a .NET consulting and training company and that’s been our bread and butter for many years. But lately, I’ve had the opportunity to get my feet wet with some Node.js projects and I’ve been learning a lot and having a lot of fun. One of the first challenges I faced was to get a comfortable development environment set up to edit and debug my Node.js code. It took no less than three different approaches before I found one that I really liked, and I want to share the journey and lessons learned with…

Read More

Fixes for common Node.js development issues in Windows

By | JavaScript, node.js, Visual Studio | 2 Comments

I remember when I first heard about Node.js. JavaScript on the server? Why would anyone want to do that? I hadn’t yet experienced the expressive power and conciseness of JavaScript, but once I did, I was hooked. Suddenly I was very interested in Node.js and started looking for a reason to jump in and start playing with it. Well, I recently got that chance, and while I am enjoying it very much, the start of my experience has had its share of bumps in the road. I’ll share a few of the problems I had and their workarounds or solutions. Install a version…

Read More

node.js integration in VS 2015 – Day 19 – 31 Days

By | node.js, Visual Studio, Web | 4 Comments

This is post 19 of 31 in the series “31 Days of VS2015 Tricks and Treats” node.js Ask, “what is node.js?” and one will receive a range of answers with the typical being, Node.js is an open-source, cross-platform runtime environment for developing server-side web applications. — Wikipedia That really doesn’t tell one much and node.js’s usefullness is far broader so I’ll give a thumbnail working description. node.js applications are written in JavaScript or one of the supersets such as TypeScript which compile to JavaScript and are typically run within the node.js runtime. The node.js runtime is available on most OS’s…

Read More