1. Open NPM in the directory you have been using for the previous tasks 2. Create...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Open NPM in the directory you have been using for the previous tasks 2. Create a folder called APP_API in the root 3. Open app.js and create a const apiRouter which requires ./APP_API/routes/foods' 4. Tell the application to use apiRouter when the route starts with '/api' with app.use 5. Open the APP API folder and create a new folder called routes 6. Create a new file inside this folder called foods.js 7. Open foods.js and follow Listing 6.1 to do the following tasks: a. Add express and express.Router() b. Create const ctrlFood which requires "../controllers/food' c. Create a route for "'/foods' with a get that calls ctriFood.getFoods and a post that calls ctriFood.createFood d. Create a route for '/foods/foodid' with a get that calls ctriFood.getSingleFood, a put that calls ctrlFood.updateFood and a delete that calls ctriFood.deleteFood e. Export the routes 8. Return to the APP API folder and create a new controllers folder 9. Create a new file inside this folder called food.js 10. For each function you defined in the routes/food.js file (getFoods, createFood, etc), create a placeholder controller like this: const getFoods = function (req, res) { res .status (200) .json (("status" : "success"}); 11. Export all the controllers you've created, so the routes/food.js file can access them: module.exports ( getFoods, createFood, getSingleFood, update Food, deleteFood 12. Verify that your basic create routes work by starting the server and going to /api/foods and /api/foods/1, it should return some simple JSON and show this to your professor 1. Open NPM in the directory you have been using for the previous tasks 2. Create a folder called APP_API in the root 3. Open app.js and create a const apiRouter which requires ./APP_API/routes/foods' 4. Tell the application to use apiRouter when the route starts with '/api' with app.use 5. Open the APP API folder and create a new folder called routes 6. Create a new file inside this folder called foods.js 7. Open foods.js and follow Listing 6.1 to do the following tasks: a. Add express and express.Router() b. Create const ctrlFood which requires "../controllers/food' c. Create a route for "'/foods' with a get that calls ctriFood.getFoods and a post that calls ctriFood.createFood d. Create a route for '/foods/foodid' with a get that calls ctriFood.getSingleFood, a put that calls ctrlFood.updateFood and a delete that calls ctriFood.deleteFood e. Export the routes 8. Return to the APP API folder and create a new controllers folder 9. Create a new file inside this folder called food.js 10. For each function you defined in the routes/food.js file (getFoods, createFood, etc), create a placeholder controller like this: const getFoods = function (req, res) { res .status (200) .json (("status" : "success"}); 11. Export all the controllers you've created, so the routes/food.js file can access them: module.exports ( getFoods, createFood, getSingleFood, update Food, deleteFood 12. Verify that your basic create routes work by starting the server and going to /api/foods and /api/foods/1, it should return some simple JSON and show this to your professor
Expert Answer:
Answer rating: 100% (QA)
To set up the API according to the given instructions follow these steps Open your commandline interface and navigate to the directory you have been u... View the full answer
Related Book For
Money Banking and Financial Markets
ISBN: 978-0078021749
4th edition
Authors: Stephen Cecchetti, Kermit Schoenholtz
Posted Date:
Students also viewed these programming questions
-
For many years you have been using your local, small-town bank. One day you hear that the bank is about to be purchased by Bank of America. From your vantage point as a retail bank customer, what are...
-
You have been using different ICs while performing lab exercises. You also have used these ICs in your course project. Like, AND, OR, XOR, Latches, Flip-Flops, Decoder, MUX, DMUX etc. Are these...
-
a. Throughout the Case Problems in this course, you have been using a Rental class that obtains all the data for rentals from Sunshine Seashore Supplies, including details about the contract number,...
-
Desmond died on 18 July 2017, having made no transfers in the previous seven years. He left his entire estate to his wife Emily, including the family home valued at 420,000. Emily died on 9 May 2020,...
-
How do assurance services differ from audit services? What are the primary drivers of the need for assurance services? Does a market for assurance services already exist or do auditors need to...
-
An investigator proposes to study the mass-transfer process for the dissolution of a single solid sphere suspended within a turbulent flow stream. Predict the variables that would be used to explain...
-
The trial balance for Silver Shovels Exploration Company does not balance. The following errors were detected: a. The cash balance is overstated by $3,000. b. Rent expense of \($390\) was erroneously...
-
On January 1, Pulse Recording Studio (PRS) had the following account balances. The following transactions occurred during January. 1. Received $ 2,500 cash on 1/ 1 from customers on account for...
-
I have to draw the budget constraint, c = (1-7)w (24 - 1),with consumption on the y-axis, and time on the x-axis. The l is leisure, c is consumption, and p is the price of the consumption good. W is...
-
Give forwarding tables for switches S1 to S4 in Figure below. Each switch should have a default routing entry, chosen to forward packets with unrecognized destination addresses toward OUT. Any...
-
1: A museum has three rooms, each with a motion sensor (M0, M1 and M2) that outputs a "1" when motion is detected. At night, the only person in the museum is one security guard who walks from room to...
-
How much money needs to be set aside every year, for the next 7 years, to purchase a new office? The money is expected to earn 8% interest compounded annually and yearly inflation is expected to be...
-
A bond with a $1,000 face value and 13 years to maturity is currently selling for $920. If the yield to maturity is 5.6%, what is the coupon rate of the bond?
-
Particles P and Q, of masses 4kg and 6 kg respectively, are attached to the ends of a light inextensible string. The string passes over a smooth fixed pulley. The system is in equilibrium with P...
-
Sekersiz Industries has 60% debt in its capital structure. Its WACC is 8% and its cost of debt is 5%. The corporate tax rate is 20%. What is the company's cost of equity capita
-
1. 320 N force is applied to a horizontal spring which stretches it by 7 cm cm to the left. What is the spring constant of this spring? 2. A 763 g mass is placed on top of a spring. The other end of...
-
A corporate bond pays 8% annual coupon rate and has $1,000 par value. It will mature in 5 years and its yield to maturity is 9%. Calculate: (1) the bond's price. (2) its Macaulay duration.
-
6 (a) Briefly develop a mathematical model of the behaviour of a copper-twisted pair cable (b) Derive the magnetic energy from: w given that: K + w, where the - - k symbols have their usual meaning...
-
If velocity were constant at 2 while M2 rose from $5 trillion to $6 trillion in a single year, what would happen to nominal GDP? If real GDP rose 3 percent, what would be the level of inflation?
-
Transparency is a key element of the monetary policy framework. a. Explain how transparency helps eliminate the problems that are created by central bank independence. b. In what way did the...
-
Assuming the chances of being paid back are the same, would a nominal interest rate of 10 percent always be more attractive to a lender than a nominal rate of 5 percent? Explain.
-
To determine an optimum sample size when sampling methods are used in a substantive test, all of the following factors must be considered except the a. Variation in the population. b. Risk levels the...
-
Which of the following sample planning factors would influence the sample size for a substantive test of details for a specific account? Expected amount of misstatements No Measure of tolerable...
-
The relationship between the sampling risk of incorrect acceptance and the sample size of substantive tests is a. Inverse. b. Positive. c. Indeterminate. d. None of the above.
Study smarter with the SolutionInn App