-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest.js
46 lines (38 loc) · 1.01 KB
/
rest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Books = new Mongo.Collection("books");
if (Meteor.isClient) {
console.log("running client");
// counter starts at 0
Session.setDefault('counter', 0);
Template.hello.helpers({
counter: function() {
return Session.get('counter');
}
});
Template.hello.events({
'click button': function() {
// increment the counter when button is clicked
Session.set('counter', Session.get('counter') + 1);
}
});
}
if (Meteor.isServer) {
Meteor.startup(function() {
// code to run on server at startup
console.log("Hello i am starting");
});
// Global API configuration
var Api = new Restivus({
useDefaultAuth: true,
prettyJson: true
});
// Generates: GET, POST on /api/items and GET, PUT, DELETE on
// /api/items/:id for the Items collection
Api.addCollection(Books);
Api.addCollection(Meteor.users);
console.log("Done adding collections");
Api.addRoute('countme', {authRequired: true}, {
get: function () {
return Books.find().count();
}
});
}