bunch of stuff

This commit is contained in:
Edin Dazdarevic
2015-05-28 17:06:59 +02:00
parent 9641f4fee7
commit 701f0844a6
7 changed files with 157 additions and 66 deletions

View File

@@ -2,42 +2,70 @@ Machines = new Mongo.Collection("machines");
Meteor.startup(function() {
// code to run on server at startup
// Global API configuration
Restivus.configure({
prettyJson: true,
useAuth: false
Picker.route('/api/machines', function(params, req, res, next) {
var allMachines = Machines.find({});
res.end(JSON.stringify(allMachines.fetch()));
});
Restivus.addCollection(Machines);
Restivus.addRoute('post/:_id', {
get: function () {
var id = this.urlParams._id; // "5"
return {hamo:1}
}
});
Restivus.addRoute('/api/templates/:type', {
Picker.route('/api/templates/:type', function(params, req, res, next) {
var type = params.type;
var fs = Meteor.npmRequire('fs');
var path = Meteor.npmRequire('path');
},{
get: {
action: function() {
var type = this.urlParams.type;
var fs = Meteor.npmRequire('fs');
var template = Async.runSync(function(done) {
// github.gists.getFromUser({user: 'arunoda'}, function(err, data) {
// done(null, data);
// });
fs.readFile(path.resolve('../public/configs/' + type + '.conf'), function(err, data) {
console.log('done!', err, data);
done(null, data);
});
var template = Async.runSync(function(done) {
// github.gists.getFromUser({user: 'arunoda'}, function(err, data) {
// done(null, data);
// });
fs.readFile('../public/configs/'+type+'.conf', function(err, data) {
done(null, data);
});
});
});
console.log('done received!', template);
res.end(template.result);
});
return template.result;
}
}
})
// Global API configuration
// Restivus.configure({
// prettyJson: true,
// useAuth: false
// });
//
// Restivus.addCollection(Machines);
// Restivus.addRoute('post/:_id', {
// get: function() {
// var id = this.urlParams._id; // "5"
// return {
// hamo: 1
// }
// }
// });
//
// Restivus.addRoute('/api/templates/:type', {
//
// }, {
// get: {
// action: function() {
// var type = this.urlParams.type;
// var fs = Meteor.npmRequire('fs');
//
// var template = Async.runSync(function(done) {
// // github.gists.getFromUser({user: 'arunoda'}, function(err, data) {
// // done(null, data);
// // });
// fs.readFile('../public/configs/' + type + '.conf', function(err, data) {
// done(null, data);
// });
//
// });
//
// return template.result;
// }
// }
// })
// Restivus.addRoute('/api/machines', {
// // authRequired: false
// }, {