Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Latest commit

 

History

History
146 lines (106 loc) · 6.77 KB

week-1.md

File metadata and controls

146 lines (106 loc) · 6.77 KB

Week 1

Always bet on JavaScript.

@BrendanEich

Visualisation of npm dependencies by @anvaka.

Table of Contents

Slides

Theory

Before you start you'll probably want to read a bit about Node, the JavaScript engine, and client vs. server-side. We'll cover this in the lecture but make sure you fully understand these concept, the resources below can help.

🎦 Watch a video about the browser versus Node.js.
🎦 Watch a video about Modules.

Playground

You can do these exercises before you start working on the assignments to get comfortable with the topics covered in class. The below workshoppers are interactive, self guided lesson modules, from NodeSchool.

Assignments

Package

Package Banner

Learn the basics of node modules and npm packages and setup a boilerplate for your own feature.

Synopsis

  • Time: 4:00h
  • Goals: subgoal 1, subgoal 2
  • Due: before week 2
  1. Create the boilerplate for the node app you are going to create. Include a package.json with a correct name, version, dependencies, and other metadata. See npm’s documentation on package.json. For examples of package.json files, see repeat-string, longest-streak, or skin-tone.

  2. Look trough the NPM registry and install a package from npm that would be helpful for your job story and try it out in index.js. Not sure what package to pick? You can try playing around with camelcase or lodash to get comfortable requiring packages and using them.

  3. Improve the developer experience of your application. Look for so called 'developer dependencies' on NPM. nodemon is a good example, it will monitor for any changes in your source and automatically restart your server. Perfect for development.

  4. Create some run scripts in your package.json to start, serve or build your application.

Ask yourself upon completion:

  • How does require work under the hood?
  • What's the difference between dependencies and devDependencies?
  • What are the differences between global and local dependencies?
  • What tasks can you run with npm run scripts?

Additional resources

🎦 Watch a video about Node Packages.
🎦 Watch a demo about NPM.

Serve

Hello World Server banner

In this assignment you’ll build a static file server with a little help from Express.

Synopsis

  • Time: 4:00h
  • Goals: subgoal 1, subgoal 2
  • Due: before week 2

Description

Create a server that handles routes and serves static files in Node.js. Feel free to write your server from scratch if you feel adventurous, otherwise express is your best option.

  • Have a couple of different routes (e.g. /about /contact)
  • Respond with a 404 Not Found if you go to a route that doesn't exist.
  • Serve static files such as JavaScript and CSS but also media files such as images

Ask yourself upon completion:

  • How does the app instance work? What makes it possible you can do things like app.get or app.listen?
  • What are the req and res parameters?
  • The confusing part is that your laptop is both the client and the server. It's a local development environment.

Additional resources

Hand-in

  1. Push your changes:
    Hand in your progess in your repository on GitHub under your username.

  2. Create an issue:
    Mark this assignment as complete by opening an issue on our GitHub issue tracker. Fill in the issue template with the correct information. Include what you did in the description of the issue.

  3. Feedback:
    Let us know what you thought of the homework, what part you spend a lot of time on and give us any feedback. Your project will be reviewed and receive feedback, so expect people to read it, and be ready for tips and tops!