I used the express-generator
package to initialize a basic project using the default template. Looking through the template’s file structure I saw the bin
folder. The bin
folder is something that I have seen a lot of but have never truly understood. I know program executables often live in this folder but I am not sure why that is the case. This curiosity took me down a rabbit hole of looking into system admining skills and tools.
Ultimately, I had to stop myself from diving too deep into something that is not immediately important to my studies. For now I will just accept that executable programs often live in the bin folder whereas the files that program depends on to run often live outside of that folder. This structure is different from the default index.js
file I have used so often. In this template the server was run with the computer executing the bin/www
program. The www
program being a shell script that included the initial hashbang (#!
) with node
as the parser associated with the script (/usr/bin/env node
).
It was interesting to see and I will definitely be coming back around to this topic and I might just go through a system administrator course in the future. For now I need to keep going through the backend dev material related to Node.js
.
TLDR;
Okay, so here are the highlights of what I did:
- Express -> Read through some of the
express
documentation aboutDEBUG
mode. - Practice -> Continued working through the practice ‘Local Library’ project in the MDN ExpressJS guide. I went through the breakdown of the project’s file structure. I think I finally have a better grasp on how to use middleware correctly with particular routes in
express
. Slowly but surely I am definitely getting more comfortable with the framework. This Honestly feels great to overcome this weakness I have had for a while now.
Express Debug Mode Notes
The express package includes a module called DEBUG
that provides log information. It provides information about express middleware functions, application mode, and status, and also provides information about the requests and responses made to the server using express.
To use this module while running the express app, set the DEBUG
environment variable to express:*
$ DEBUG=express:* node index.js
The output generated on running the command is would look something like this:
express:application set "x-powered-by" to true +0ms
express:application set "etag" to 'weak' +1ms
express:application set "etag fn" to [Function: generateETag] +1ms
express:application set "env" to 'development' +1ms
express:application set "query parser" to 'extended' +0ms
express:application set "query parser fn" to [Function: parseExtendedQueryString] +0ms
express:application set "subdomain offset" to 2 +0ms
express:application set "trust proxy" to false +1ms
express:application set "trust proxy fn" to [Function: trustNone] +0ms
express:application booting in development mode +0ms
express:application set "view" to [Function: View] +1ms
express:application set "views" to 'C:\\Users\\Jamal Ahmed\\Documents\\projects\\programming_projects\\web_projects\\course_projects\\the_odin_
project\\projects_theodinproject\\nodejs_projects\\local_library_practice_project\\views' +0ms
express:application set "jsonp callback name" to 'callback' +0ms
express:router use '/' query +1ms
express:router:layer new '/' +0ms
express:router use '/' expressInit +1ms
express:router:layer new '/' +0ms
express:router:route new '/about' +0ms
express:router:layer new '/about' +0ms
express:router:route get '/about' +1ms
express:router:layer new '/' +0ms
express:router:route new '/contact-me' +0ms
express:router:layer new '/contact-me' +0ms
express:router:route get '/contact-me' +1ms
express:router:layer new '/' +0ms
express:router:route new '/' +0ms
express:router:layer new '/' +0ms
express:router:route get '/' +0ms
express:router:layer new '/' +1ms
express:router:route new '*' +0ms
express:router:layer new '*' +0ms
express:router:route get '*' +0ms
express:router:layer new '/' +0ms
These logs help in finding any bug in the program and determining which part of the program is causing the problem.
Setting Options in the Debugger
Sometimes you may not want the entire log but only the logs from a specific part of the program, for example, only the logs of the router
or application
, then you can do so by setting the DEBUG
environment variable as express:<area-to-log>
and then running the command. For example:
$ DEBUG=express:router node index.js
This gives logs only of the router
part. Similarly, you can do for application as well.
$ DEBUG=express:application node index.js
If you want to log for both the router
and the application
you can do so by running the code:
DEBUG=express:application,express:router node index.js
In the example above, we set DEBUG to express:*
. Here, *
indicates that all functionality run by express are included in the logs and will be displayed.
Goal For Round 8 of the #100DaysofCode Challenge
This is my eighth round of the “#100daysofcode” challenge. I will be continuing my work from round five, six, and seven into round eight. I was working through the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. My goal was to become more familiar with algorithms and data structures. This goal was derived from my goal to better understand operating systems and key programs that I use in the terminal regularly e.g. Git. This goal was in turn derived from my desire to better understand the fundamental tools used for coding outside of popular GUIs. This in turn was derived from my desire to be a better back-end developer.
I am currently putting a pause on the algorithm work to build some backend/full stack projects. I primarily want to improve my skills with the back-end from an implementation perspective. I have improved tremendously in terminal and CLI skills but I lost focus due to how abstract the algorithm concepts got. I wanted to work on things that were more tangible until I can get to a position where I could directly benefit from improving my algorithm skills and theoretical knowledge. So that’s the focus right now. Build my backend skills and prove my full stack capabilities by building some dope projects.
Again, I still have no idea if my path is correct but I am walking down this road anyways. Worst case scenario I learn a whole bunch of stuff that will help me out on my own personal projects. Best case scenario I actually become one of those unicorn developers that go on to start a billion dollar company… You never know LOL.