Coder Social home page Coder Social logo

httprequests's Introduction

Content Creators Contracting

Project Overview

In this project, you have been hired by a "professional" company, Content Creators Contracting, to write a function that signs their HTTP requests with the proper content types. Normally this behavior is handled by the browser, but they really mucked things up in thinking they could solve this problem better. Now none of their files are loading properly.

They have managed to craft the code to get the file extension from a string containing a filename and store it in a variable called 'extension': const extension = filename.match(/.*\.([^\.]*)$/)[1];. In this code, if filename were equal to 'index.html', the string 'html' would be stored in extension. However, they're struggling to write the rest of the function.

It's up to you to save their site and their business.

You can view what the final version of this project should look like here.

The goal of this project is to get you running a testing suite and implementing the functionality laid out in the testing suite.

How To Begin

To start, download the starting code for this project here. After downloading the zip folder, double click it to uncompress it and access the contents of this project.

Implementation Details

To complete this project, your code will need to contain the following:

  • A function called getContentType, which will take a string representing a filename and return the proper content-type extension. You will need to implement the functionality for determining content types for 'text/html', 'text/css', 'image/jpeg', and 'text/plain'. For more information on this functionality, run the testing suite (detailed below).

All of your code should be written in js/request-logic.js. Use the descriptions above and the testing suite (discussed below) to guide implementation of all necessary functionality.

To demo the site, open index.html in your browser (by double clicking index.html in a file browser or dragging it into your Internet browser). You will be writing JavaScript code that uses new syntax (you will learn more about this later in the intensive), so you will need to use the most up-to-date version of Chrome to ensure your code runs correctly. If your version of Chrome is too old, correctly-written code may still not run as expected.

Testing

A testing suite has been provided for you, checking for all essential functionality and edge cases.

To run these tests, first open the root project directory in your terminal. Then run npm install to install all necessary testing dependencies (you will only need to do this step once). Finally, run npm run test. You will see a list of tests that ran with information about whether or not each test passed. After this list, you will see more specific output about why each failing test failed.

As you implement functionality, run the tests to ensure you are creating the correctly named function and that it returns the proper values. The tests will additionally help you identify edge cases that you may not have anticipated when first writing the function.

httprequests's People

Contributors

globaltechiee 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.