Skip to content

rnewstead1/rest-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST Workshop

Accompanying slides.

Prerequisites

Download the Postman app - you will have to create a free account. We will use this to test our API.

Clone this repo and run npm i && npm run dev and the app should start at http://localhost:5000

Task

Build a REST API with the following endpoints:

  • Return all the jobs
  • Add a job
  • Update the title of a job
  • Delete a job
  • Return a single job by id
  • Return employer details for a job
  • Return all jobs for an employer

Data

Some initial data is found in jobs.db and employers.db. This data will be loaded into an in-memory datastore when the application starts up.

You can add more following this data structure. Assume all fields are required.

Example job:

{
  _id: '1', // unique
  title: 'English teacher',
  employerId: '1',
  candidates: [
    {
      name: 'Jon Snow',
      id: '10098'
    }
  ]
}

Example employer:

{
  _id: '1', // unique
  name: 'Beyond The Wall School', // unique
  type: 'Secondary',
  numberOfPupils: 100
}

Talking points

  • What response code does each endpoint return?
  • What happens if there's an error?
  • Which REST verb have you used to update the job title, and why?
  • How have you structured your url to get a single job? How do you pass the id? What other ways can you do this?
  • How have you designed the APIs to get employer details? What other ways can you do this?

Next steps

Use supertest to write some automated tests for your api using mocha (or a test framework of your choice).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published