update models to be loopback compliantgs
parent
88a512d96c
commit
a6dc24521d
|
@ -114,8 +114,8 @@ Project Structure
|
|||
| **controllers**/home.js | Controller for home page (index). |
|
||||
| **controllers**/user.js | Controller for user account management. |
|
||||
| **controllers**/challenges.js | Controller for rendering the challenges. |
|
||||
| **models**/User.js | Mongoose schema and model for User. |
|
||||
| **models**/Challenge.js | Mongoose schema and model for Challenge. |
|
||||
| **models**/user.json | Mongoose schema and model for User. |
|
||||
| **models**/challenge.json | Mongoose schema and model for Challenge. |
|
||||
| **public**/ | Static assets (fonts, css, js, img). |
|
||||
| **public**/**js**/application.js | Specify client-side JavaScript dependencies. |
|
||||
| **public**/**js**/main_0.0.2.js | Place your client-side JavaScript here. |
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
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);
|
|
@ -1,39 +0,0 @@
|
|||
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);
|
|
@ -1,21 +0,0 @@
|
|||
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);
|
|
@ -1,18 +0,0 @@
|
|||
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);
|
|
@ -1,16 +0,0 @@
|
|||
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);
|
|
@ -1,27 +0,0 @@
|
|||
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);
|
|
@ -1,52 +0,0 @@
|
|||
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);
|
|
@ -1,204 +0,0 @@
|
|||
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);
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "challenge",
|
||||
"base": "PersistedModel",
|
||||
"trackChanges": false,
|
||||
"idInjection": true,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"unique": true
|
||||
},
|
||||
"difficulty": "string",
|
||||
"description": "array",
|
||||
"tests": "array",
|
||||
"challengeSeed": "array",
|
||||
"challengeType": "string",
|
||||
"MDNlinks": "array",
|
||||
"nameCn": "string",
|
||||
"descriptionCn": "array",
|
||||
"nameFr": "string",
|
||||
"descriptionFr": "array",
|
||||
"nameRu": "string",
|
||||
"descriptionRu": "array",
|
||||
"nameEs": "string",
|
||||
"descriptionEs": "array",
|
||||
"namePt": "string",
|
||||
"descriptionPt": "array"
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"acls": [],
|
||||
"methods": []
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "comment",
|
||||
"base": "PersistedModel",
|
||||
"trackChanges": false,
|
||||
"idInjection": true,
|
||||
"properties": {
|
||||
"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",
|
||||
"defaultFn": "now"
|
||||
}
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"acls": [],
|
||||
"methods": []
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "fieldGuide",
|
||||
"base": "PersistedModel",
|
||||
"trackChanges": false,
|
||||
"idInjection": true,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"unique": true
|
||||
},
|
||||
"dashedName": {
|
||||
"type": "string",
|
||||
"unique": false
|
||||
},
|
||||
"description": {
|
||||
"type": "array",
|
||||
"unique": false
|
||||
}
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"acls": [],
|
||||
"methods": []
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "job",
|
||||
"base": "PersistedModel",
|
||||
"trackChanges": false,
|
||||
"idInjection": true,
|
||||
"properties": {
|
||||
"position": "string",
|
||||
"company": "string",
|
||||
"logoUrl": "string",
|
||||
"postingUrl": "string",
|
||||
"copy": "array"
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"acls": [],
|
||||
"methods": []
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "nonprofit",
|
||||
"base": "PersistedModel",
|
||||
"trackChanges": false,
|
||||
"idInjection": true,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"unique": true
|
||||
},
|
||||
"requestedDeliverables": "array",
|
||||
"whatDoesNonprofitDo": "string",
|
||||
"websiteLink": "string",
|
||||
"stakeholderName": "string",
|
||||
"stakeholderEmail": "string",
|
||||
"endUser": "string",
|
||||
"approvedDeliverables": "array",
|
||||
"projectDescription": "string",
|
||||
"logoUrl": "string",
|
||||
"imageUrl": "string",
|
||||
"estimatedHours": 0,
|
||||
"interestedCampers": [],
|
||||
"confirmedCampers": [],
|
||||
"currentStatus": "string"
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"acls": [],
|
||||
"methods": []
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Nonprofit', nonprofitSchema);
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"name": "bonfire",
|
||||
"base": "PersistedModel",
|
||||
"trackChanges": false,
|
||||
"idInjection": true,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"unique": true
|
||||
},
|
||||
"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": ""
|
||||
}
|
||||
"difficulty": "string",
|
||||
"description": "array",
|
||||
"tests": "array",
|
||||
"challengeSeed": "array",
|
||||
"MDNlinks": {
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"acls": [],
|
||||
"methods": []
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
{
|
||||
"name": "bonfire",
|
||||
"base": "PersistedModel",
|
||||
"trackChanges": false,
|
||||
"idInjection": true,
|
||||
"properties": {
|
||||
"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": "string",
|
||||
"uncompletedBonfires": "array",
|
||||
"completedBonfires": [{
|
||||
"_id": "string",
|
||||
"name": "string",
|
||||
"completedWith": "string",
|
||||
"completedDate": "string",
|
||||
"solution": "string"
|
||||
}],
|
||||
"uncompletedCoursewares": "array",
|
||||
"completedCoursewares": [{
|
||||
"completedDate": {
|
||||
"type": "string",
|
||||
"defaultFn": "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": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"sendMonthlyEmail": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"challengesHash": {},
|
||||
"currentChallenge": {},
|
||||
"completedChallenges": [{
|
||||
"completedDate": "number",
|
||||
"_id": "string",
|
||||
"name": "string",
|
||||
"completedWith": "string",
|
||||
"solution": "string",
|
||||
"githubLink": "string",
|
||||
"verified": "boolean",
|
||||
"challengeType": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
}
|
||||
}],
|
||||
"uncompletedChallenges": "array"
|
||||
},
|
||||
"validations": [],
|
||||
"relations": {},
|
||||
"acls": [],
|
||||
"methods": []
|
||||
}
|
Loading…
Reference in New Issue