This file contains 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
/* | |
Expected File tree: | |
spec/ | |
helpers/ | |
spec_helper.js | |
support/ | |
jasmine.json | |
spec.js | |
*/ |
This file contains 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 up CORS headers from client-side | |
app.use(function(req, res, next) { | |
res.header("Access-Control-Allow-Origin", "*"); | |
res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS"); | |
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization, Access-Control-Allow-Credentials"); | |
res.header("Access-Control-Allow-Credentials", "true"); | |
next(); | |
}); |
This file contains 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": "Alabama" }, | |
{ "name": "Alaska" }, | |
{ "name": "Arizona" }, | |
{ "name": "Arkansas" }, | |
{ "name": "California" }, | |
{ "name": "Colorado" }, | |
{ "name": "Connecticut" }, | |
{ "name": "Delaware" }, | |
{ "name": "Florida" }, |
This file contains 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
// package.json | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
// Usual commands now namespaced | |
"sql:migrate:undo": "npm run sql db:migrate:undo:all", | |
"sql:migrate": "npm run sql db:migrate", | |
"sql:seed:undo": "npm run sql db:seed:undo:all", | |
"sql:seed": "npm run sql db:seed:all", |
This file contains 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
// routers/sessions.js | |
// Destroy | |
var onDestroy = (req, res) => { | |
// Display flash message that logout | |
// was successful | |
req.flash('success', 'Successfully logged out!'); | |
req.session.currentUser = null; | |
res.redirect('/login'); |
This file contains 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
{ | |
"development": { | |
"database": "demo_exploring_mongoose_development", | |
"host": "localhost" | |
}, | |
"test": { | |
"database": "demo_exploring_mongoose_test", | |
"host": "localhost" | |
}, | |
"production": { |
This file contains 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 bodyParser = require('body-parser') | |
var app = express() | |
// parse application/x-www-form-urlencoded | |
app.use(bodyParser.urlencoded({ extended: false })) | |
// parse application/json | |
app.use(bodyParser.json()) |
This file contains 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 path = require('path'); | |
// Set options | |
var config = { | |
"config": "./config/sequelize.json", | |
"migrations-path": "./migrations/sequelize", | |
"seeders-path": "./seeds/sequelize", | |
"models-path": "./models/sequelize" | |
}; |
This file contains 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
// helpers/index.js | |
var fs = require('fs'); | |
var path = require('path'); | |
var express = require('express'); | |
var basename = path.basename(__filename); | |
var Helpers = {}; |