-
Notifications
You must be signed in to change notification settings - Fork 0
/
keystone.js
102 lines (81 loc) · 2.98 KB
/
keystone.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
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
96
97
98
99
100
101
102
require('babel-register')({ only: /\/graphql\/.*/ });
// Simulate config options from your production environment by
// customising the .env file in your project's root folder.
require('dotenv').config();
// Require keystone
var keystone = require('keystone');
var pkg = require('./package.json');
// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
// and documentation.
keystone.init({
'name': 'PenangJS',
'brand': 'JavaScript Malaysia',
'back': '/me',
'less': 'public',
'static': 'public',
'favicon': 'public/favicon.ico',
'views': 'templates/views',
'view engine': 'pug',
'view cache': false,
'emails': 'templates/emails',
'auto update': true,
'mongo': process.env.MONGO_URI || 'mongodb://localhost/' + pkg.name,
'session': true,
'session store': 'mongo',
'cookie secret': process.env.COOKIE_SECRET || 'sydjs',
'auth': true,
'user model': 'User',
'google api key': process.env.GOOGLE_BROWSER_KEY,
'google server api key': process.env.GOOGLE_SERVER_KEY,
'default region': 'my',
'ga property': process.env.GA_PROPERTY,
'ga domain': process.env.GA_DOMAIN,
'cloudinary secure': true,
'basedir': __dirname,
});
// Load your project's Models
keystone.import('models');
// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js
keystone.set('locals', {
_: require('lodash'),
moment: require('moment'),
js: 'javascript:;',
env: keystone.get('env'),
utils: keystone.utils,
plural: keystone.utils.plural,
editable: keystone.content.editable,
google_api_key: keystone.get('google api key'),
ga_property: keystone.get('ga property'),
ga_domain: keystone.get('ga domain'),
host: (function () {
// if (keystone.get('env') === 'staging') return 'http://sydjs-beta.herokuapp.com';
if (keystone.get('env') === 'production') return 'https://javascript.my';
return (keystone.get('host') || 'http://localhost:') + (keystone.get('port') || '3000');
})(),
});
// keystone.set('email locals', {
// utils: keystone.utils,
// ,
// });
// Load your project's Routes
keystone.set('routes', require('./routes'));
keystone.set('nav', {
meetups: ['meetups', 'talks', 'rsvps'],
members: ['users', 'organisations'],
posts: ['posts', 'post-categories', 'post-comments'],
links: ['links', 'link-tags', 'link-comments'],
});
// Start Keystone to connect to your database and initialise the web server
if (!process.env.MAILGUN_API_KEY || !process.env.MAILGUN_DOMAIN) {
console.log('----------------------------------------'
+ '\nWARNING: MISSING MAILGUN CREDENTIALS'
+ '\n----------------------------------------'
+ '\nYou have opted into email sending but have not provided'
+ '\nmailgun credentials. Attempts to send will fail.'
+ '\n\nCreate a mailgun account and add the credentials to the .env file to'
+ '\nset up your mailgun integration');
}
keystone.start();