Skip to content

Commit

Permalink
new yo mongoose with highscores hooked up to set. renamed zest.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsabend committed Jan 8, 2015
0 parents commit 61b85ce
Show file tree
Hide file tree
Showing 8,693 changed files with 1,242,396 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "public/bower_components",
"interactive" : false
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
21 changes: 21 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"white": true
}
73 changes: 73 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
// Configure a mochaTest task
mochaTest: {
test: {
options: {
reporter: 'spec'
},
src: ['test/**/*.js']
}
},
watch: {
options: {
livereload: true,
},
express: {
files: [ '*.js','routes/*.js', 'models/*.js', 'config/*.js' ],
tasks: [ 'express:dev' ],
options: {
spawn: false // Without this option specified express won't be reloaded
}
}
},
express: {
options: {
port : 3000,
node_env: 'development'
},
dev: {
options: {
script: 'app.js',
node_env: 'development'
}
},
prod: {
options: {
script: 'app.js',
node_env: 'production'
}
}
},
open: {
server: {
url: 'http://localhost:<%= express.options.port %>'
}
}
});

grunt.registerTask('test', 'mochaTest');

grunt.registerTask('server', function(arg) {
if(arg && arg == 'prod')
{
grunt.task.run([
'express:prod',
'open',
'watch'
]);
}
else
{
grunt.task.run([
'express:dev',
'open',
'watch'
]);
}
});
grunt.registerTask('default', [ 'server' ]);
grunt.registerTask('dist', [ 'server:prod' ]);

};
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Set_server

Doc, are you telling me that you built a time machine out of a delorean.
74 changes: 74 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'use strict';

// Module dependencies.
var express = require('express'),
path = require('path'),
fs = require('fs'),
methodOverride = require('method-override'),
morgan = require('morgan'),
bodyParser = require('body-parser'),
errorhandler = require('errorhandler');

var app = module.exports = exports.app = express();

app.locals.siteName = "Set_server";

// Connect to database
var db = require('./config/db');
app.use(express.static(__dirname + '/public'));


// Bootstrap models
var modelsPath = path.join(__dirname, 'models');
fs.readdirSync(modelsPath).forEach(function (file) {
require(modelsPath + '/' + file);
});

var env = process.env.NODE_ENV || 'development';

if ('development' == env) {
app.use(morgan('dev'));
app.use(errorhandler({
dumpExceptions: true,
showStack: true
}));
app.set('view options', {
pretty: true
});
}

if ('test' == env) {
app.use(morgan('test'));
app.set('view options', {
pretty: true
});
app.use(errorhandler({
dumpExceptions: true,
showStack: true
}));
}

if ('production' == env) {
app.use(morgan());
app.use(errorhandler({
dumpExceptions: false,
showStack: false
}));
}

app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(methodOverride());
app.use(bodyParser());

// Bootstrap routes/api
var routesPath = path.join(__dirname, 'routes');
fs.readdirSync(routesPath).forEach(function(file) {
require(routesPath + '/' + file)(app);
});

// Start server
var port = process.env.PORT || 3000;
app.listen(port, function () {
console.log('Express server listening on port %d in %s mode', port, app.get('env'));
});
16 changes: 16 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "set-server",
"version": "0.0.1",
"description": "Sample Description",
"private": true,
"dependencies": {
"jquery": "latest"
},
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
28 changes: 28 additions & 0 deletions config/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';
var mongoose = require('mongoose');

var config = {
"db": "highScores",
"host": "localhost",
"user": "",
"pw": "",
"port": 27017
};

var port = (config.port.length > 0) ? ":" + config.port : '';
var login = (config.user.length > 0) ? config.user + ":" + config.pw + "@" : '';
var uristring = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || "mongodb://" + login + config.host + port + "/" + config.db;

var mongoOptions = { db: { safe: true } };

// Connect to Database
mongoose.connect(uristring, mongoOptions, function (err, res) {
if(err){
console.log('ERROR connecting to: ' + uristring + '. ' + err);
}else{
console.log('Successfully connected to: ' + uristring);
}
});


exports.mongoose = mongoose;
16 changes: 16 additions & 0 deletions models/score.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;

var fields = {
username: { type: String },
highscore: { type: Number },
gif: { type: String },
created: { type: Date , default: Date.now }
};

var scoreSchema = new Schema(fields);

module.exports = mongoose.model('Score', scoreSchema);
1 change: 1 addition & 0 deletions node_modules/.bin/_mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/bower

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/grunt-open

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 61b85ce

Please sign in to comment.