Setting up a minimal HTTP server with connect is just a matter of few lines:
var connect =require('connect');var http =require('http');var app =connect();app.use('/',function(req,res){res.end('Welcome to Connect!\n');});http.createServer(app).listen(6500);
Similar approach can be take with express:
var express =require('express');var app =express();app.get('/',function(req,res){res.send('Welcome to Express!\n');});app.listen(6500);
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.
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 Gist
On 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.