Solution: Building APIs
Let's practice implementing a working version of the Credit-Check API.
In this challenge, the task was to use the design assets to implement a working API service using Node.js and the DARRT library. The three key tasks are these:
- Install the DARRT library into the Node.js project.
- Update the DARRT files (data, action, resources, representations, and transitions).
- Once the API is completed, run a happy-path validator script.
Installing the DARRT Library
Execute the following command:
npm run dev
This should start up the API project and output something that looks like this:
> credit-check@1.0.0 dev /credit-check
> nodemon index
[nodemon] 2.0.18
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index index.js`
listening on port 8181!
Note: Don’t forget to execute
npm run dev
in the second terminal. Make sure you set the path by executingcd usercode/credit-check
before doing so. Click the “+
” sign to open the second terminal.
Now test the API ...