The express.js top level function for creating app objects, and more.

When creating an express.js project of any kind the first thing that I work with is the express top level function. It is the function that is exported when grabbing at express with require when making the typical app.js file. This function is used to create instances of an app object, and it also has some additional methods attached to it as well.

Read More

Sending a file with express.js using the response sendFile method

When making an express.js project there are a few response methods that can be used to respond to a request with some kind of content. All of these methods of interest are in the standard response object that is one of the three arguments when making a function that will be used with an app method like app.get.

In this post I will be writing about the response send file method for just simply sending a file that is to be displayed in the browser. This differs from other methods like the response download method that is useful for serving up a file that is to be downloaded to the client as an attachment to the local file system. If I want to make a path where the user will be prompted to download a binary for there operating system I would want to use res.download, but if I just want to display an image file as content to be displayed for a path then I would want to use res.sendFile.

Read More

Expressjs mega post a good starting point for all this expressjs related

For my posts on expressjs I want to try something different, have a post that acts as an index for all my content on expressjs. This will serve as a central guide for all things with expressjs, at least much of the must know stuff that one should be aware of. This post will also branch off into many other posts on expressjs, and will likely grow over time as I keep adding, and updating content on express. Getting solid with expressjs is not something that will happen over night, and it branches off into other subjects like database management, deployment, front end frameworks, and security. So this seems like it might be a good idea to help keep things more organized.

Read More

Managing file downloads in express with the response download method

As I continue expanding on express.js this month today I thought I would write about the response download method, which is one of the many methods in express that are part of the standard response object that I might write about more this week. The download response method will send a file as an attachment rather than the content to be displayed, so it does differ a little from the send file response method that would be used as a way to send a file as browser display content, rather than an attachment to be downloaded to a place on a clients local file system.

This download method of the response object of a middleware function is useful if you want to have some kind of path that will work as a way to deliver a file as a download when a link is clicked, or something to that effect. When doing so the user should end up being prompted if they want to download the file, and if it is something they want they can then click to downloaded to a location on there local file system. It is very easy to use, you do not have to worry about setting the proper headers or anything like that it does it all for you so all that has to be done basically is to just call a method in the response object.

Read More

Getting started with micro services using node.js, and express.js

In my experience so far when making some kind of full stack web application I run into problems with the programing becoming to complex. Often is the case so far that I end up doing everything in a single application. That is rendering and delivering the client system, authentication, database management, and so forth all within a single package. When it comes to simple hobby apps that are not that complex, and may never have more than 50 visitors at any given moment, maybe this is not such a bad thing. However as a project grows in both complexity, and or popularity there is a threshold where it becomes desirable or necessary to break things down more.

Read More