-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (28 loc) · 1.38 KB
/
index.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
/**
* This is "Main" where all of the modules are imported, configured, and tied together and the app is started.
*/
const PatreonApi = require('./src/PatreonApiInterface');
const fetchCommsModule = require('./src/fetchCommsApiModule');
const DataStore = require('./src/InMemoryDataStore');
const Policy = require('./src/Policy');
const server = require('./src/Server');
const config = require('./config.json');
const clientId = config.clientId || "";
const clientSecret = config.clientSecret || "";
const oauthRedirectPath = '/oauth/redirect';
//Note, the value of redirectUrl must match exactly with a value provided in the Patreon app web form
const redirectUrl = `http://${config.hostname}:${config.port}${oauthRedirectPath}`;
console.log(`Redirect URI: ${redirectUrl}`);
const patreonApi = PatreonApi(clientId, clientSecret, redirectUrl, fetchCommsModule);
const dataStore = DataStore();
const minimumPledgeCents = config.minimumPledgeCents || 500;
const policy = Policy({minimumPledgeCents, magicUsers: config.magicUsers || []});
//TODO: make a generic logging interface that wraps this and pass the wrapper into the server
const logger = require('node-file-logger');
logger.SetUserOptions({
timeZone: 'Etc/UTC',
folderPath: './logs/',
dateBasedFileNaming: true,
fileNamePrefix: 'Access_'
});
server.initialize(config.port, oauthRedirectPath, patreonApi, dataStore, policy, logger);