Coder Social home page Coder Social logo

backend-connecting-it-all-cors's Introduction

Backend-Connecting-It-All-CORS

Connecting it all: CORS You've been hired as a backend API developer at Smarty plants! Another developer created the API, and the frontend developer keeps getting CORS errors when they try to use it. You have been tasked with enabling CORS on specific URLs so that the frontend developers can keep working.

To succeed at this challenge, you'll need to demonstrate that you can do the following:

Modify existing Express Router configuration to enable CORS. You will not need to make any edits to HTML or CSS for this project.

Instructions Your goal for this lesson is to get the tests to pass. To do so, you will be modifying an existing API server with two resources, users and plants, in addition to error handling. Your server should follow the structure you've learned in the course.

Existing files File path Description src/app.js Contains the Express application. You will not need to make changes to this file. src/data/plants-data.js Contains the plants data. This is the shape of the plant data that the API will send and receive. You can add or remove plants if you like. src/data/users-data.js Contains the users data. This is the shape of the user data that the API will send and receive. You can add or remove users if you like. src/errors/errorHandler.js Exports the error handler function for use by the Express application. src/errors/methodNotAllowed.js Exports the 405 Method Not Allowed handler function for use by the Express application. src/errors/notFound.js Exports the 404 Not Found handler function for use by the Express application. src/plants/plants.controller.js Contains middleware and handlers for plants. You will not need to make changes to this file. src/plants/plants.router.js Contains the router configuration for plants. Add CORS middleware to this file as needed to pass the tests. src/server.js Contains the server code. You will not need to make changes to this file. src/users/users.controller.js Contains middleware and handlers for users. You will not need to make changes to this file. src/users/users.router.js Contains the router configuration for users. Add CORS middleware to this file as needed to pass the tests. src/utils/nextId.js Exports the nextId function. Use this function anytime you need to assign a new id. You will not need to make changes to this file. test/cors.test.js Tests for the necessary CORS configuration. You will not need to make changes to this file. Tasks Complete the following tasks to pass the tests and this assessment.

In the src/plants/plants.router.js file, make the necessary changes to enable CORS for the entire router. In the src/users/users.router.js file, enable CORS for any GET to /users, and /users/:userId. Once these tasks are complete, all tests should pass.

backend-connecting-it-all-cors's People

Contributors

holly-ellington avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.