Starting from:

$25

Assignment 2 solution-Node.js and HTTP Requests

Assignment Two
Purpose The purpose of this assignment is to start working with Node.js and become more familiar with HTTP requests.
You will create a standard Node.js server to handle incoming HTTP requests and then respond with information about the request. The server should be able to read incoming headerandqueryparametersandincludethisinformationintheresponse. Theservershould also only accept certain incoming requests and block others.
You may use any of the standard packages included in Node.js or any third-party packages to complete this assignment.
Requirements • Create a Node.js server that accepts requests and creates responses and host it on Apigee. – The server should accept GET, POST, PUT and DELETE requests. – Any other requests coming in should be rejected. • If the server accepts a request, it should respond with information about the request. – The server should respond with the name and value of any query parameters sent in. If no headers or query parameters are sent in, then the response should say so. – Some headers are generated automatically, like host and user-agent. It’s fine to have these appear in the response. • If the server rejects a request, it should respond with a simple statement saying it doesn’t support the HTTP method. • The server should have four different URNs that only accept a given HTTP method, while reject the other methods. – /gets should only accept GET requests while rejecting others. – /posts should only accept POST requests while rejecting others. – /puts should only accept PUT requests while rejecting others. – /deletes should only accept DELETE requests while rejecting others. – Any requests made to the base URL (no URN specified) should also be rejected. • Include a small SoapUI project that can shows all the requirements have been met. – This project should include valid requests, as well as requests that fail (sending a POST request to /gets, etc.).
1
Resources • http://apigee.com/docs/api-services/content/overview-nodejs-apigee-edge – Apigee provides excellent documentation on how to create an application with Node.js. • http://nodejs.org/ – Although its possible to finish this assignment only in Apigee, their editor is limited and testing can be cumbersome. It may be helpful to install a local version of Node.js and test there. Node API documentation can also be found here.

More products