Skip to content

Instantly share code, notes, and snippets.

Avatar

Devesh Kumar deveshkumar

  • WhiteShark
  • India
View GitHub Profile
View marionette.handlebars.js
/**
Usage: Just include this script after Marionette and Handlebars loading
IF you use require.js add script to shim and describe it in the requirements
*/
(function(Handlebars, Marionette) {
Marionette.Handlebars = {
path: 'templates/',
extension: '.handlebars'
};
View marionette.handlebars.js
/**
Usage: Just include this script after Marionette and Handlebars loading
IF you use require.js add script to shim and describe it in the requirements
*/
(function(Handlebars, Backbone) {
var Marionette = Backbone.Marionette;
Marionette.Handlebars = {
path: 'templates/',
@deveshkumar
deveshkumar / 1.js
Created Jun 30, 2013
5 Code Signals
View 1.js
app.get('/api/friends', function(req,res,next){
Friends.find({user_id: req.currentUser.id }).exec(function (err, friend_list) {
if (err) {
return next(err);
}
if (friend_list) {
res.send(friend_list);
} else {
return next(new NotFound('Could not find any such Friend'));
}
@deveshkumar
deveshkumar / 3.js
Created Jun 30, 2013
5 Code Signals
View 3.js
app.post('/api/friends', function(req, res,next){
new_friend = new Friends({ name: req.body.name,user_id: req.currentUser.id });
new_friend.save();
res.send(new_friend);
});
@deveshkumar
deveshkumar / 5.js
Created Jun 30, 2013
5 Code Signals
View 5.js
app.delete('/api/friends/:_id', function (req, res){
return Friends.findById(req.params._id, function (err, friend) {
return friend.remove(function (err) {
if (!err) {
console.log("Friend removed");
return res.send('');
} else {
console.log(err);
}
});
@deveshkumar
deveshkumar / 2.js
Created Jun 30, 2013
5 Code Signals
View 2.js
app.get('/api/friends/:_id',function(req,res,next){
Friends.findOne({ '_id': req.params._id , user_id: req.currentUser.id})
.exec(function (err, friend_list) {
if (err) {
return next(err);
}
if (friend_list) {
res.send(friend_list);
} else {
return next(new NotFound('Could not find any such Friend'));
@deveshkumar
deveshkumar / 4.js
Created Jun 30, 2013
5 Code Signals
View 4.js
app.put('/api/friends/:_id', function (req, res){
return Friends.findById(req.params._id, function (err, friend) {
friend.name = req.body.name;
return friend.save(function (err) {
if (!err) {
console.log("updated friend");
} else {
console.log(err);
}
return res.send(friend);