Let’s Code It: Static Site Generator

Traditionally, if you wanted to create a blog or website that you can update easily without having to directly edit HTML, you’d use a tool like WordPress. The basic flow for serving a website from a CMS like WordPress is as follows:

  1. Store content (e.g. “posts”) in a database
  2. Store display configuration (templates, CSS, etc.) separately
  3. When a visitor requests a page, run a script to…
    1. Pull the content from the database
    2. Read the appropriate template
    3. Put them together to build page HTML
    4. Send HTML to the user

Read more

Working with LoopBack Authentication and Authorization

One of LoopBack’s core features is the ability to lock down access to your APIs and define exactly who can do what with your data. LoopBack provides multiple tools to make this easy, but it’s helpful to see a real (although simple) application demonstrating the complete process of securing your APIs.

In this post I’ll demonstrate how to:

* Add support for users to your application.
* Add user registration and login/logout.
* Create rules for your API that follow common patterns, for example, only a logged in user can create content and only the owner of content can modify it.
Read more

Working with File Storage and LoopBack

I’ve got a confession to make: I absolutely love LoopBack. How much do I love it? Before I even joined the StrongLoop team at IBM I was blogging on LoopBack and giving presentations on it as well. I basically told the person interviewing me that it didn’t really matter if they hired me or not; I was going to evangelize LoopBack because I thought it was the coolest thing since sliced bread and beer. In general, I love LoopBack and every aspect of it. However, it doesn’t mean that it is perfect. Today I’m going to discuss a feature that is—in my opinion—somewhat “rough”. I’m not saying to avoid it, not at all, just be prepared for a somewhat bumpy ride. Ready?

So, one of the things that LoopBack makes incredibly easy is handling data in a persistence system. You define a model, let’s say Cat, various properties and types, and then LoopBack can handle persisting that in a variety of different storage mechanisms, from Oracle to MySQL to MongoDB. It just plain works, which is cool. However, the data we’re typically dealing with are simple strings represented in JSON. What about binary data?
Read more

Interactive Debugging with Node.js

A “step-through debugger” (also called an “interactive debugger” or just “debugger”) is a powerful tool that can be very handy when your application isn’t behaving the way you expect. You can use it to pause your application’s code execution to:

  • Inspect or alter application state.
  • See the code execution path (“call stack”) that leads to the currently-executing line of code.
  • Inspect the application state at earlier points on the code execution path.

Interactive debuggers* are familiar to every Java developer (among others), but they are less well known in the JavaScript world. This is unfortunate, both because debuggers can help  diagnose logic issues, and because the JavaScript debugging tools today are the best and easiest to use they’ve ever been! This post will introduce the Node.js debugging tools in Visual Studio Code (VS Code) for programmers who have never used a debugger before. Read more

The Node.js Debug Module: Advanced Usage

In a previous post, I explained the debug module and how to use it for basic debugging.  I recently used it to help me understand complex interactions between events in Leaflet and Leaflet.Editable. Before going over that, however, I’m going to lay the groundwork with a couple organizational tips that makes debug easier to use. This post assumes you have either used debug or read the previous post…. Read more