This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.loginprocess = function (req, res) { | |
| connection.query( | |
| 'SELECT * FROM mocha_test_table WHERE user_name="'+req.body.user_name+ | |
| '" AND email="'+req.body.email+'";',function(err,results){ | |
| if(results.length===0) { | |
| res.render('../views/login'); | |
| } else { | |
| res.render('../views/form', { | |
| user_name:req.body.user_name, | |
| email:req.body.email, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.login = function (req, res) { | |
| res.render('../views/login'); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.home = function (req, res) { | |
| res.render('../views/home'); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var connection = require('../database'); | |
| connection.query('CREATE TABLE IF NOT EXISTS mocha_test_table(user_name varchar(10),'+ | |
| 'email varchar(10),fname varchar(10),lname varchar(10));', function(err) {if(err){console.log(err);}}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = function(app, serverport) { | |
| app.set('view engine', 'hbs'); | |
| var form = require('./controllers/form'); | |
| app.get('/', form.home); | |
| app.get('/login’, form.login); | |
| app.post('/login', form.loginprocess); | |
| app.post('/form', form.formprocess); | |
| app.listen(serverport); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .text { | |
| font: normal 15px Arial, Helvetica, sans-serif; | |
| text-align: center; | |
| padding: 10px; | |
| } | |
| .large-text { | |
| font:normal 20px Arial, Helvetica, sans-serif; | |
| text-align: center; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var express = require('express'); | |
| var mysql = require('mysql'); | |
| var app = express(); | |
| app.use(express.bodyParser()); // need this to see the body in req object | |
| var serverport = 3000; | |
| require('./routes')(app, serverport); | |
| app.use('/styles', express.static(__dirname + '/styles')); | |
| console.log('The node server is now running on port ' + serverport); | |
| module.exports = app; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var async = require('async'), | |
| request = require('supertest'), | |
| should = require('should'), | |
| app = require('../server'), | |
| connection = require('../database'); | |
| describe('Req 1: Landing page functionality', function(){ | |
| before(function (done) { | |
| this.timeout(5000); | |
| async.series([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "name-of-the-project-but-in-one-word", | |
| "description": "a short description about the project”, | |
| "version": "what version number of the project this is, usually 0.0.1", | |
| "dependencies": { | |
| "mocha": "1.14.0", | |
| "supertest": "0.8.0", | |
| "should": "2.0.2", | |
| "async": "0.2.9", | |
| "mysql": "2.0.0-alpha9" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Set indentation to 2 spaces, convert tabs to spaces. | |
| set expandtab tabstop=2 shiftwidth=2 softtabstop=2 |