ExpressWorks: an Automated Express.js/Node.js Workshop and Tutorial

TL;DR: ExpressWorks is an automated Express.js/Node.js workshop.

ExpressWorks is an automated Express.js/Node.js workshop.

ExpressWorks is an automated Express.js/Node.js workshop.

During fun times at NodeConf 2013 one of the workshops was stream-adventures by @substack and @maxogden. It’s done in the form of an old text-based console game. Recently, it was metamorphosed into nodeschool.io with the addition of learning resources on LevelDB, Node itself and other topics. The menu and validation framework was abstracted into the workshopper library.

Inspired by all these resources, I put together ExpressWorks during our 36 hour hackathon at DocuSign. You can visit npmjs.org/expressworks or github.com/azat-co/expressworks. While for those who have Node.js (and NPM) installed already, this simple command will do the trick:

$ sudo npm install -g expressworks@latest

In case you have any suggestions or found bugs (I’m sure there are some!), submit GitHub issues at github.com/azat-co/expressworks/issues.

Here is the list of exercises as of now (they’ll be more later!).

[Sidenote]: If you liked this post and want to learn more about Node.js, MongoDB, Express.js and React.js; if you are an experienced programmer who wants to learn MEAN or MERN quickly in a convenient format (not spending hours and hours searching for free blog posts on internet—you get what you pay for, right?), then take a look at this offer.

I'm giving access to ALL of my online courses (5), ALL of my ebooks (5) and ALL cheatsheets (4) in a one convenient BUNDLE. But that's not all! Often, courses and books are not enough. Often you need to ask an expert. That's why I included a 1 hour mentorship with me with the bundle!

Start mastering React.js, Node.js, MongoDB/Mongoose and Express.js. Upgrade your career with my mentorship. Become familiar with full stack JavaScript+Node.js stack. Acquire new skills and confidence in the future by getting the bundle. [End of sidenote.]

Hello World

Create an Express.js app that runs on localhost:3000, and outputs “Hello World!” when somebody goes to root ‘/home’.

process.argv[2] will be provided by expressworks to you, this is the port number.

Jade

Create an Express.js app with a home page (/home) rendered by jade template engine, that shows current date (toDateString).

Good Old Form

Write a route (‘/form’) that processes HTML form input (

) and prints backwards the str value.

Static

Apply static middleware to server index.html file without any routes. The index.html file is provided and usable via process.argv[3] value of the path to it. However, you can use you’re own file with this content:

  <html>
    <head>
      <link rel="stylesheet" type="text/css" href="/main.css"/>
    </head>
    <body>
      <p>I am red!</p>
    </body>
  </html>

Stylish CSS

Style your HTML from previous example with some Stylus middleware. The path to main.styl file is provided in process.argv[3] or you can create your own file/folder from these:

  p
    color red

The index.html file:

Sidenote: If you like this post and interested in a corporate on-site JavaScript, Node.js and React.js training to boost productivity of your team, then contact NodeProgram.com.

  <html>
    <head>
      <title>expressworks</title>
      <link rel="stylesheet" type="text/css" href="/main.css"/>
    </head>
    <body>
      <p>I am red!</p>
    </body>
  </html>

Param Pam Pam

Create an Express.js server that processes PUT /message/:id requests, e.g., PUT /message/526aa677a8ceb64569c9d4fb.

As the response of this request return id SHA1 hashed with a date:

  require('crypto')
    .createHash('sha1')
    .update(new Date().toDateString().toString() + id)
    .digest('hex')

What’s in Query

Write a route that extracts data from query string in the GET /search URL route, e.g., ?results=recent&include_tabs=true, and then transforms outputs it back to the user in JSON format.

JSON Me

Write a server that reads a file (file name is passed in process.argv[3]), parses it to JSON and outputs the content to the user with res.json(object).

To contact Azat, the main author of this blog, submit the contact form.

Also, make sure to get 3 amazing resources to FREE when you sign up for the newsletter. Simple. Easy. No commitment.

4 thoughts on “ExpressWorks: an Automated Express.js/Node.js Workshop and Tutorial

  1. Pingback: Express.js Fundamentals - Modern Web

  2. Pingback: Node.js FUNdamentals: A Concise Overview of The Main Concepts | webapplog: Full-Stack Software Engineering

  3. Pingback: Express.js FUNdamentals: An Essential Overview of Express.js | webapplog: Node.js, Express.js and JavaScript Tutorials

  4. daslicht

    I wish there would be a kind of IntelliSense/Codecompletion for JavaScript
    AND HTML…
    …so that you can just access variables needed on the Client, via CodeCompletion on the ServerSide. :) Coding without remembering VariableNames,just hit ctrl+space done.
    This would be much more fun.

Leave a Reply

Your email address will not be published. Required fields are marked *