19
common/models/Bonfire.js
Normal file
19
common/models/Bonfire.js
Normal file
@@ -0,0 +1,19 @@
|
||||
var mongoose = require('mongoose');
|
||||
/**
|
||||
*
|
||||
* @type {exports.Schema}
|
||||
*/
|
||||
|
||||
var bonfireSchema = new mongoose.Schema({
|
||||
name: {
|
||||
type: String,
|
||||
unique: true
|
||||
},
|
||||
difficulty: String,
|
||||
description: Array,
|
||||
tests: Array,
|
||||
challengeSeed: Array,
|
||||
MDNlinks: [String]
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Bonfire', bonfireSchema);
|
32
common/models/Challenge.js
Normal file
32
common/models/Challenge.js
Normal file
@@ -0,0 +1,32 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {exports.Schema}
|
||||
*/
|
||||
|
||||
var challengeSchema = new mongoose.Schema({
|
||||
name: {
|
||||
type: String,
|
||||
unique: true
|
||||
},
|
||||
difficulty: String,
|
||||
description: Array,
|
||||
tests: Array,
|
||||
challengeSeed: Array,
|
||||
// 0 = html, 1 = javascript only, 2 = video, 3 = zipline, 4 = basejump
|
||||
challengeType: Number,
|
||||
MDNlinks: Array,
|
||||
nameCn: String,
|
||||
descriptionCn: Array,
|
||||
nameFr: String,
|
||||
descriptionFr: Array,
|
||||
nameRu: String,
|
||||
descriptionRu: Array,
|
||||
nameEs: String,
|
||||
descriptionEs: Array,
|
||||
namePt: String,
|
||||
descriptionPt: Array
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Challenge', challengeSchema);
|
39
common/models/Comment.js
Normal file
39
common/models/Comment.js
Normal file
@@ -0,0 +1,39 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
var commentSchema = new mongoose.Schema({
|
||||
associatedPost: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
originalStoryLink: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
originalStoryAuthorEmail: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
body: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
rank: {
|
||||
type: Number,
|
||||
default: -Infinity
|
||||
},
|
||||
upvotes: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
author: {},
|
||||
comments: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
commentOn: {
|
||||
type: Number,
|
||||
default: Date.now()
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Comment', commentSchema);
|
21
common/models/Courseware.js
Normal file
21
common/models/Courseware.js
Normal file
@@ -0,0 +1,21 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {exports.Schema}
|
||||
*/
|
||||
|
||||
var coursewareSchema = new mongoose.Schema({
|
||||
name: {
|
||||
type: String,
|
||||
unique: true
|
||||
},
|
||||
difficulty: String,
|
||||
description: Array,
|
||||
tests: Array,
|
||||
challengeSeed: Array,
|
||||
// 0 = html, 1 = javascript only, 2 = video, 3 = zipline, 4 = basejump
|
||||
challengeType: Number
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Courseware', coursewareSchema);
|
18
common/models/FieldGuide.js
Normal file
18
common/models/FieldGuide.js
Normal file
@@ -0,0 +1,18 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
var fieldGuideSchema = new mongoose.Schema({
|
||||
name: {
|
||||
type: String,
|
||||
unique: false
|
||||
},
|
||||
dashedName: {
|
||||
type: String,
|
||||
unique: false
|
||||
},
|
||||
description: {
|
||||
type: Array,
|
||||
unique: false
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('FieldGuide', fieldGuideSchema);
|
16
common/models/Job.js
Normal file
16
common/models/Job.js
Normal file
@@ -0,0 +1,16 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {exports.Schema}
|
||||
*/
|
||||
|
||||
var jobSchema = new mongoose.Schema({
|
||||
position: String,
|
||||
company: String,
|
||||
logoUrl: String,
|
||||
postingUrl: String,
|
||||
copy: Array
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Job', jobSchema);
|
27
common/models/Nonprofit.js
Normal file
27
common/models/Nonprofit.js
Normal file
@@ -0,0 +1,27 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {exports.Schema}
|
||||
*/
|
||||
|
||||
var nonprofitSchema = new mongoose.Schema({
|
||||
name: String,
|
||||
requestedDeliverables: Array,
|
||||
whatDoesNonprofitDo: String,
|
||||
websiteLink: String,
|
||||
stakeholderName: String,
|
||||
stakeholderEmail: String,
|
||||
endUser: String,
|
||||
approvedDeliverables: Array,
|
||||
projectDescription: String,
|
||||
logoUrl: String,
|
||||
imageUrl: String,
|
||||
estimatedHours: 0,
|
||||
interestedCampers: [],
|
||||
confirmedCampers: [],
|
||||
// "confirmed", "started", "completed", "aborted"
|
||||
currentStatus: String
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Nonprofit', nonprofitSchema);
|
52
common/models/Story.js
Normal file
52
common/models/Story.js
Normal file
@@ -0,0 +1,52 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
var storySchema = new mongoose.Schema({
|
||||
headline: {
|
||||
type: String,
|
||||
unique: false
|
||||
},
|
||||
timePosted: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
link: {
|
||||
type: String,
|
||||
unique: false
|
||||
},
|
||||
metaDescription: {
|
||||
type: String,
|
||||
default: '',
|
||||
unique: false
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
unique: false
|
||||
},
|
||||
originalStoryAuthorEmail: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
rank: {
|
||||
type: Number,
|
||||
default: -Infinity
|
||||
},
|
||||
upVotes: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
author: {},
|
||||
comments: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
image: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
storyLink: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Story', storySchema);
|
204
common/models/User.js
Normal file
204
common/models/User.js
Normal file
@@ -0,0 +1,204 @@
|
||||
var bcrypt = require('bcrypt-nodejs');
|
||||
var mongoose = require('mongoose');
|
||||
require('mongoose-long')(mongoose);
|
||||
|
||||
var Long = mongoose.Types.Long;
|
||||
var userSchema = new mongoose.Schema({
|
||||
email: {
|
||||
type: String,
|
||||
lowercase: true,
|
||||
trim: true,
|
||||
sparse: true
|
||||
},
|
||||
password: String,
|
||||
facebook: String,
|
||||
twitter: String,
|
||||
google: String,
|
||||
github: String,
|
||||
linkedin: String,
|
||||
tokens: Array,
|
||||
progressTimestamps: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
profile: {
|
||||
username: {
|
||||
type: String,
|
||||
sparse: true,
|
||||
lowercase: true,
|
||||
trim: true
|
||||
},
|
||||
bio: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
gender: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
location: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
picture: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
linkedinProfile: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
githubProfile: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
codepenProfile: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
twitterHandle: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
facebookProfile: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
portfolio: {
|
||||
website1Link: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
website1Title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
website1Image: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
website2Link: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
website2Title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
website2Image: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
website3Link: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
website3Title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
website3Image: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
resetPasswordToken: String,
|
||||
sentSlackInvite: false,
|
||||
resetPasswordExpires: Date,
|
||||
uncompletedBonfires: Array,
|
||||
completedBonfires: [{
|
||||
_id: String,
|
||||
name: String,
|
||||
completedWith: String,
|
||||
completedDate: Long,
|
||||
solution: String
|
||||
}],
|
||||
uncompletedCoursewares: Array,
|
||||
completedCoursewares: [{
|
||||
completedDate: {
|
||||
type: Long,
|
||||
default: Date.now()
|
||||
},
|
||||
_id: String,
|
||||
name: String,
|
||||
completedWith: String,
|
||||
solution: String,
|
||||
githubLink: String,
|
||||
verified: Boolean
|
||||
}],
|
||||
completedFieldGuides: [],
|
||||
uncompletedFieldGuides: [],
|
||||
currentStreak: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
longestStreak: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
needsSomeDataModeled: { type: Boolean, default: false},
|
||||
|
||||
// needsMigration has been deprecated, use needsSomeDataModeled
|
||||
needsMigration: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
sendMonthlyEmail: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
challengesHash: {},
|
||||
currentChallenge: {},
|
||||
completedChallenges: [{
|
||||
completedDate: Long,
|
||||
_id: String,
|
||||
name: String,
|
||||
completedWith: String,
|
||||
solution: String,
|
||||
githubLink: String,
|
||||
verified: Boolean,
|
||||
challengeType: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
}],
|
||||
uncompletedChallenges: Array
|
||||
});
|
||||
|
||||
/**
|
||||
* Password hashing Mongoose middleware.
|
||||
*/
|
||||
|
||||
userSchema.pre('save', function(next) {
|
||||
var user = this;
|
||||
|
||||
if (!user.isModified('password')) { return next(); }
|
||||
|
||||
bcrypt.genSalt(5, function(err, salt) {
|
||||
if (err) { return next(err); }
|
||||
|
||||
bcrypt.hash(user.password, salt, null, function(err, hash) {
|
||||
if (err) { return next(err); }
|
||||
user.password = hash;
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Helper method for validationg user's password.
|
||||
*/
|
||||
|
||||
userSchema.methods.comparePassword = function(candidatePassword, cb) {
|
||||
bcrypt.compare(candidatePassword, this.password, function(err, isMatch) {
|
||||
if (err) { return cb(err); }
|
||||
cb(null, isMatch);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = mongoose.model('User', userSchema);
|
Reference in New Issue
Block a user