made with esnextbin
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
var app = feathers() | |
.configure(feathers.rest()) | |
.configure(feathers.primus({ | |
transformer: 'engine.io' | |
}, function(primus) { | |
primus.on('connection', function() { | |
logger.info('Server primus ready'); | |
}); | |
})) | |
.configure(require('feathers-hooks')) |
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 = function(app) { | |
var resourcePath = '/api/questions'; | |
app.use(resourcePath, auth.isAuthenticated, new MongooseService(Question)); | |
app.service(resourcePath) | |
.before({ | |
create: [setAuthor], | |
update: [updateLastActivityDate], | |
remove: [checkRemovePermissions], |
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
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var ObjectId = mongoose.Schema.Types.ObjectId; | |
var answerSchema = new Schema({ | |
description: {type: String, required: true}, | |
fileId: String, | |
fileName: String, | |
author: { | |
email: 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
/** | |
* [Action] Add an answer to a question | |
* | |
* @param req {String} - Identifier of the question to add to | |
* @param res {Object} - Data of the new answer | |
*/ | |
function addAnswer(request, response) { | |
var questionId = request.params.questionId; | |
var newAnswer = request.body; |
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 = function(app) { | |
var resourcePath = '/api/questions'; | |
router | |
.get('/', findQuestions) | |
.post('/', createQuestion) | |
.get('/:questionId', getQuestion) | |
.delete('/:questionId', deleteQuestion) | |
.get('/:id/answers', findAnswers) | |
.post('/:id/answers', addAnswer); |
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
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var answerSchema = new Schema({ | |
description: {type: String, required: true}, | |
fileId: String, | |
createdAt: {type: Date, 'default': Date.now}, | |
question: {type: Schema.Types.ObjectId, ref: 'questions', required: true}, | |
author: {type: Schema.Types.ObjectId, ref: 'accounts', required: true}, | |
})); |
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
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var questionSchema = new Schema({ | |
description: {type: String, required: true}, | |
author: {type: Schema.Types.ObjectId, ref: 'user', required: true}, | |
tags: Array, | |
fileId: String, | |
createdAt: {type: Date, default: Date.now}, | |
lastActivityAt: {type: Date, default: Date.now} |
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 = function(grunt) { | |
require('load-grunt-tasks')(grunt); | |
grunt.registerTask('default', 'concurrent:dev'); | |
grunt.initConfig({ | |
concurrent: { | |
dev: { | |
tasks: ['nodemon:dev', 'watch:js', 'watch:sass'], |
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
// Handle specific permissions | |
app.service(resourcePath) | |
.before({ | |
update: handleUpdatePermissions | |
}); | |
/** | |
* Handle permissions when updating a project | |
* | |
* @param hook {Object} - |