]> git.r.bdr.sh - rbdr/lgtm/blob - index.js
cc5c3b9685c936539abb988627ce9396e4cd509c
[rbdr/lgtm] / index.js
1 'use strict';
2
3 const Config = require('./config/config');
4 const Koa = require('koa');
5 const KoaStatic = require('koa-static');
6 const Nunjucks = require('nunjucks');
7 const RecordFetcher = require('./lib/record_fetcher');
8
9 const internals = {};
10
11 internals.run = () => {
12
13 Nunjucks.configure(Config.templateDirectory);
14
15 internals.app = Koa();
16
17 internals.app.use(KoaStatic(Config.staticDirectory));
18
19 const recordFetcher = new RecordFetcher();
20 internals.app.use(function * () {
21
22 const record = yield recordFetcher.fetch();
23 const parsedTemplate = Nunjucks.render('index.html.njk', record);
24
25 this.body = parsedTemplate;
26 });
27
28 console.log(' .');
29 console.log(' /');
30 console.log(' +-----+');
31 console.log(` | o o | - Listening Gladly, Try Me: ${Config.port}`);
32 console.log(' +-----+');
33 console.log(' +---------+');
34 console.log(' /| [][] |\\');
35 console.log(' || | |');
36 console.log(' || | \\c');
37 console.log(' ^+---------+');
38 console.log(' (.) ');
39 internals.app.listen(Config.port);
40 };
41
42 internals.run();