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
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)" |
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
#!/bin/bash | |
timezone="Australia/Melbourne" | |
redis_version=2.6.11 | |
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/ | |
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server | |
############################################### | |
# To use: | |
# wget https://gist.github.com/raw/4497007/866287a130a5a4ca12a132fd52e391cde39f4f3f/install-redis.sh |
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
// 1. Include Packages | |
var express = require("express"); | |
var bodyParser = require('body-parser'); | |
var mongoose = require("mongoose"); | |
var cors = require("cors"); | |
var logger = require('morgan'); | |
// 2. Include Configuration | |
var config = require('./config'); |
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
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 | |
}; |
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
// 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 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 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 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 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 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 |
OlderNewer