Code Monkey home page Code Monkey logo

mark-nodejs-proj--my-little-server's Introduction

module level methods tags
mark-nodejs
1
team
pair
solo
wip

My Little Server

Creative Commons License

This is part of Academy's technical curriculum for The Mark. All parts of that curriculum, including this project, are licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

We're now going to run your first server and play around with a few existing endpoints that it has.

Learning Outcomes

  • Run an Express server locally
  • Send back a JSON response in an Express route handler
  • Identify when a route handler function is executed
  • Test HTTP GET requests in the browser
  • Test HTTP GET requests in Postman

Exercise 1: Installing and running

Success criterion: you can view evidence your server is running at localhost:4000

Firstly, clone this repository to your local machine, then install dependencies and run it locally.

Exercise 2: Viewing responses in Postman

Try making GET requests to some of the following:

  • localhost:4000
  • localhost:4000/hits
  • localhost:4000/hits-stealth

etc.

(Some routes will give you back the same response each time, and others won't. Why is that?)

Exercise 3: Writing your own Express route

🎯 Success criterion: you can visit localhost:5050/hello-world, localhost:5050/ponies/random and localhost:5050/history in the browser, with the expected behaviour below.

Now, you're going to try making changes to the server - in particular, you're going to change the port which it runs on, and try adding some endpoints of your own.

/hello-world

Should respond with the following JSON data:

{
  "english": "Hello world!",
  "esperanto": "Saluton mondo!",
  "hawaiian": "Aloha Honua",
  "turkish": "Merhaba Dünya!"
}

/ponies/random

Shows a single random pony from ponies.json. It should be possible to hit the route twice and get back two different ponies.

/history

Shows a list of which (active) routes have been hit in chronological order.

For example, if you visited the following routes after starting your server:

  • /ponies
  • /hits
  • /history
  • /um-what-is-this
  • /
  • /history

Then the response should be something like:

{
  "routes": [
    "/ponies",
    "/hits",
    "/history",
    "/",
    "/history"
  ]
}

(where /um-what-is-this is ignored, because it isn't a defined server endpoint)

mark-nodejs-proj--my-little-server's People

Contributors

richardcrng avatar nbogie avatar mat-krol 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.