Accompanying slides.
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
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
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
}
- 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?
Use supertest to write some automated tests for your api using mocha (or a test framework of your choice).