Our apps need to query and store lots of information. We want to make sure that you have a good understanding of JavaScript and Node.js fundamentals. Can you build a simple API that can read data from and write data to JSON files with Node.js while following Outlier's best practices?
Build an API with the following:
- Endpoints
- PUT /:student-id/:propertyName(/:propertyName)
- Stores data within
/data/${studentId}.json
. - If that file or property doesn't exist it is created.
- Should also set nested properties:
curl -X PUT -d '{ "score": 98 }' http://localhost:1337/rn1abu8/courses/calculus/quizzes/ye0ab61
would mean thatrequire('./data/rn1abu8.json').courses.calculus.quizzes.ye0ab61.score === 98
- Stores data within
- GET /:student-id/:propertyName(/:propertyName)
- Retrieves data from
/data/${studentId}.json
. Returns 404 if that file or property doesn't exist. - Should also retrieve nested properties:
curl http://localhost:1337/rn1abu8/courses/calculus
- Retrieves data from
- DELETE /:student-id/:propertyName(/:propertyName)
- Removes data from
/data/${studentId}.json
. Returns 404 if that file or property doesn't exist. - Should also remove nested properties.
- Removes data from
- PUT /:student-id/:propertyName(/:propertyName)
- Tests
- Each endpoint should have its own test
How to attempt this challenge:
- Create a new repo in your account and note the git url
- Clone this repo
- Solve the challenge
- Set your new repo as the origin:
git remote set-url origin ${your repo url}
- Push your solution to your repo
You must follow these steps for your solution to be accepted -- forks or other methods will not be considered.