Giter VIP home page Giter VIP logo

node-drills's Introduction

Node Drills

Each standalone app below builds on the previous app(s). The instructions given are only for the current app, with the assumption that you don't need repeat instructions for the previous steps.

App 1 - Setup

Create a package.json file and install/save dependencies (like express, body-parser, etc).

App 2 - Listen

Set up an express server that listens on port 3000.

App 3 - Get and post

Create GET and POST endpoints for the items array. Send the results with an ok status code.

App 4 - JS files

Export the data in the data.js file and require it in your index.js file. Create GET and POST endpoints for the data and send the results with an ok status code.

App 5 - CRUD, Queries and params

Create CRUD endpoints on the supplied data. You will want to use it, and mimic it's format when adding new data.

    1. Create an endpoint to GET all objects.
    1. Create an endpoint to POST a new object.
    1. Create an endpoint to get one item by index/id. Hint: Use req.params
  • 1b) Update endpoint #1 to look for query parameters and get only matching items.
    1. Create an endpoint to remove an object by index/id. Hint) Use req.params
    1. Create an endpoint that can update one object by id. Hint: Use req.query to determine which properties to update

App 6 - Serve Static Files

Use express to serve the static files in the public folder.

App 7 - Sessions

Use express sessions to save data to the session using a POST endpoint and access that saved data using a GET endpoint.

App 8 - Middleware

  • Create a top-level middleware function that is used on every request (keyword USE). This function can be as simple as logging something to the console.
    • Create two endpoints to test that your middleware function runs on every request and that the endpoints work properly.

App 9 - Middleware 2

  • Create a middleware function that checks to see if there is a current user logged in (see the login endpoint to see what happens when someone logs in). If there is no user logged in, end the function with a forbidden or unauthorized status code. If there is a user, return next.
  • Apply that middleware to all routes dealing with admin things.
  • Test your middleware. If you try to hit the admin endpoints without logging in first, you should see an empty response and your forbidden or unauthorized status code. If you log in first, the request will be completed.

App 10 - The Whole Shebang

If you have time, create a whole front to back app that uses a front end rather than Postman.

node-drills's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.