Skip to content

Instantly share code, notes, and snippets.

@nbogie
Last active June 7, 2019 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbogie/9bdfd66d9a67a228aa07f738eb4b84a8 to your computer and use it in GitHub Desktop.
Save nbogie/9bdfd66d9a67a228aa07f738eb4b84a8 to your computer and use it in GitHub Desktop.

Node Assessment: Creating a Web API

You must create a node app which provides a back-end JSON Web API for a "To-Do List".

It will run on Glitch.

Background Information: what is a "To-Do List"?

Here's a screenshot of a front-end for a To-Do List app.

Note: You will NOT create a front-end today, only a back-end! However, this shows the kind of data you will work with.

example-gui-todolist

Start by remixing our example server

Requirements

Data model

Each To-Do item is an object with the following properties:

Name Type Example
id number 17
description string "Buy stamps"
completed boolean false

However:

  • The id property must be initialised to a unique id by the server when the object is created
  • The completed property must be initialised to false by the server when the object is created

An example of a completed To-Do item:

{
 "id": 10,
 "description": "Do React homework",
 "completed": true
}

What actions does my API need to support?

The following actions must be available on your API

  • Read all of the To-Do items
  • Read ONE To-Do item, by ID.
  • Delete a To-Do item, by ID, to remove it completely from your list.
  • Create a new To-Do item
    • The id property must be assigned by the server to a unique id when the object is created
    • The completed property must be initialised to false by the server when the object is created
  • Update a To-Do item, allowing description string or completed status to be changed.

In all cases:

  • Use todos as the name of the resource in all of your routes. For example, one route might be GET /todos/17
  • Use JSON objects to pass To-Do items. (See "Data Model", above).
  • Return suitable status codes when user input is missing, unsuitable, or matching item(s) cannot be found.

Where should I store my To-Do list items?

To store your data, use the todos global array which has already been created for you in the code.

At the end of the assessment...

From your Glitch project, follow these steps:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment