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
bundle install | |
guard init |
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
# --- snip | |
group :development do | |
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code. | |
gem 'web-console', '>= 3.3.0' | |
gem 'listen', '>= 3.0.5', '< 3.2' | |
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring | |
gem 'spring' | |
gem 'spring-watcher-listen', '~> 2.0.0' | |
gem 'guard' | |
gem 'guard-rspec' |
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
sudo yum install tmux |
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
bundle install | |
rails g rspec:install |
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
# --- snip | |
group :development, :test do | |
# Call 'byebug' anywhere in the code to stop execution and get a debugger console | |
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] | |
gem 'rspec-rails', '~> 3.6' | |
gem 'capybara' | |
end | |
# --- /snip |
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
mkdir testapp | |
cd testapp | |
rvm use ruby-2.4.1@testapp --ruby-version --create | |
rails new . -T |
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
// 1. Load the Person model | |
var Person = require('../models/person.js'); | |
// 2. Get a paginated list of all People | |
exports.list = function(req, res){ | |
var query = {}; | |
var page = req.params.page || 1; | |
var options = { | |
select: 'first last', | |
page: page |
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
// 1. Include required modules | |
var mongoose = require('mongoose'), | |
Schema = mongoose.Schema, | |
mongoosePaginate = require('mongoose-paginate'), | |
bcrypt = require('bcryptjs'); | |
// 2. Define the MongoDB schema for the people collection | |
var personSchema = new Schema({ | |
first : {type: String, required: 'FirstNameInvalid'}, | |
last : String, |
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
// 1. Include config and modules | |
var config = require('./config'); | |
var moment = require('moment'); | |
var jwt = require('jwt-simple'); | |
var Auth = require('./controllers/auth.js'); | |
var People = require('./controllers/people.js'); | |
// 2. Authentication Middleware | |
function ensureAuthenticated(req, res, next) { | |
if (!req.headers.authorization) { |
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 = { | |
// 1. MongoDB | |
MONGO_URI: process.env.MONGO_URI || 'mongodb://localhost/apijwt', | |
// 2. JWT | |
TOKEN_SECRET: process.env.TOKEN_SECRET || 'pvpnCCZfwOF85pBjbOebZiYIDhZ3w9LZrKwBZ7152K89mPCOHtbRlmr5Z91ci4L', | |
// 3. Express Server Port | |
LISTEN_PORT: process.env.LISTEN_PORT || 3000 | |
}; |