-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathattachd.js
More file actions
95 lines (82 loc) · 1.53 KB
/
attachd.js
File metadata and controls
95 lines (82 loc) · 1.53 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Attachd API
* (c) All Rights Reserved - Nate Ferrero
*
* @author Nate Ferrero
*/
var amna = module.exports = require('amna');
/**
* Load amna things
*/
amna.registerThings([
'Attachment',
'Thread',
'User'
]);
/**
* Add GoogleAPIs service
*/
amna.registerServices(['GoogleAPIs']);
/**
* What model to allow as createdBy
*/
amna.createdByThing = 'User';
/**
* Set View Engine
*/
amna.set('view engine', 'ejs');
/**
* Authentication
*/
amna.authentication = function () {
return {
/**
* Allow login with Google and ask for access to Gmail API
*/
google: amna.things.User.model.findOrCreateFromGoogle,
/**
* Save User on the session data
*/
serializeUser: function (user, done) {
done(null, user.id);
},
/**
* Load User from the session data
*/
deserializeUser: function (id, done) {
amna.things.User.model.findById(id, done);
}
};
};
/**
* Register amna modules under /api
*/
amna.registerModules('/api', [
'attachments',
'threads',
'users'
]);
/**
* Root controller
*/
var RootController = amna.controller();
/**
* API Home Page
*/
RootController.get('/', function (self) {
self.scope.user = self.req.user;
self.render('index');
});
/**
* Register amna modules on the root
*/
amna.registerModules([
/**
* Serve views
*/
RootController,
/**
* Serve static content
*/
amna.static(__dirname + '/public')
]);