HTTP, Connect, Express
Date 23/09/2014
Setting up a minimal HTTP server with connect
is just a matter of few lines:
Similar approach can be take with express
:
Adding a middleware in both connect
and express
is pretty trivial:
The response-time
middleware adds back end execution time header on the request, which can be used for testing.
Another perhaps more useful middleware is called body-parser
which can be used to retrive the form values once such a form has been submitted.
Please note that in order to have the above middlewares available to your application, as well as connect
or express
, they need to be installed locally first, for example:
The task for the day
Create a group of three members, of which one is the owner of the given new repository, and the two others are marked as its contributors.
Half of the class will use Connect for the given task, while the other half shall use Express.
Application requirements:
Run a web server that shows a feedback form in its index page, started with a command
npm start
The feedback form contains these items:
Name
Email
Feedback content
Submit button
The form should be sent to the back end with a post request
The input fields needs to be validated both front end and back end for not being empty and email being valid
Valid feedback should be send to an email address configured via
package.json
OR send as a GistOn successful form sending the page should show a suitable gif animation
On any error cases, the form should remain usable and point out the possible errors
Use of existing npm modules is encouraged
All self made JavaScript code should be under linting rules, which can be run with
npm test
Application logic is separated to different files and used as modules
Divide the work for all the three members and work together in the same repository.
Once the work has started, add a link to the main repository in the list below.
List of projects
Links to the project repositories, along with the group member names.
Links related to the lecture subject
Examples related to the tasks
HTML5 validation via required
and pattern
properties. http://html5pattern.com/
Reading values from package.json
package.json
Last updated
Was this helpful?