-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (25 loc) · 1.12 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
const { SimpleDB } = require('aws-sdk');
const R = require('ramda');
const axios = require('axios');
const botBuilder = require('claudia-bot-builder');
const botFactory = require('./src/bot');
// eslint-disable-next-line node/no-missing-require
const { apiKey, organization } = require('./challonge');
const region = require('./aws-region');
const challongeServiceFactory = R.applySpec(require('./src/challonge.service'));
const handlersFactory = R.applySpec(require('./src/handlers'));
const userRepositoryFactory = R.applySpec(require('./src/users').repository);
const api = axios.create({
baseURL: 'https://api.challonge.com/v1/',
params: {
api_key: apiKey,
},
});
const simpleDb = new SimpleDB({ region });
const challongeService = challongeServiceFactory({ api, organization });
const userRepository = userRepositoryFactory(simpleDb);
const handlers = handlersFactory({ challongeService, userRepository });
const bot = botFactory(handlers);
// TODO this is an async operation; we don't know now if things go wrong...
userRepository.initialize();
module.exports = botBuilder(bot, { platforms: ['slackSlashCommand'] });