Node Practice: Replace

A smaller and simpler project than the last two, almost a break! This is one of a few simpler projects for you to get some practice working on basic node apps from start to finish.

Index


Learning Objectives

Programming Skills

  • Debugging Node apps in VSC
  • Using npm: installing dependencies, running scripts
  • Understanding what "fullstack" means
  • Using branches

Node.js & Express Skills

  • Reading and writing from the File System
  • Correctly using Sync & Async file system manipulations
  • Writing Express routes with different verbs and URL parameters
  • Using Async/Await to write more readable code

Other People's Code

  • Navigating larger directory structures
  • Understanding code you didn't write
  • Setting up and running other people's projects
  • Contributing to existing code bases

API's

  • Explaining why you can't run an API with the browser
  • Running API's with Node.js & VSC
  • Testing API's with Postman
  • Understanding the need for CORS
  • URL Request Parameters
  • Sending values in the Request Body

TOP


Getting Started

Before you can get started writing your routes you'll want to make sure all dependencies are installed.

Step 0 is to clone this repo. Then you can move on to ...

Running the API

Installing Dependencies

  1. npm install

Running the API

  • npm run dev
  • (this project has no frontend, use Postman for testing)

Running the Tests

  • npm run test or node test

TOP


Your Task

Pass the Tests

In ./logic/index.js write the function described by the tests in ./test.

The file ./logic/sandbox.js is there for you to experiment and debug your function.

Write the CLI

In the file ./cli.js write a script that allows a user to use your logic function from the command line. There is are more detailed instructions in the file itself.

Write the Routes

Write the routes described in ./server.js. When your API works, a user can

  • get a list of of all files in ./files
  • add a new file to the directory
  • use your logic function to update the files in ./files
  • get the latest test report

TOP


Helpful Links

Debugging JS Servers In VSC

Node.js Tutorials

These tutorials will introduce you to a bunch of new features in Node that you haven't seen in the Browser. While you're following these tutorials, it's important to remember that at it's core Node.js is still JavaScript. Everything you've learned so far (except for the DOM & fetch :) is still true! The Event Loop, Classes, Closure, Arrays, Objects, Variables, this., it's all still the same.

The tutorials below will introduce to what's new and what's special about Node. But don't forget to take some time and solve a few of the JavaScript Exercises above to get used to working with plain, vanilla JS in the terminal.

fs: Synchronous & Async

API's and Express

Node.js is a JavaScript runtime environment capable of writing Web Servers and API's all by itself. But it's a bit annoying. Express is a great and easy to use framework to help you write API's and Web Servers by handling all of the boring stuff for you so you can focus on what your app does.

Postman - an app for testing your API's without using a browser.

TOP