forked from philipheinser/ember-lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (23 loc) · 704 Bytes
/
index.js
File metadata and controls
30 lines (23 loc) · 704 Bytes
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
'use strict';
var config = require('./app.json');
var redis = require('redis'),
coRedis = require('co-redis'),
koa = require('koa');
var app = koa(),
client = redis.createClient(
config.env.REDIS_PORT.value,
config.env.REDIS_HOST.value
),
dbCo = coRedis(client);
client.auth(config.env.REDIS_SECRET.value);
app.use(function* () {
var indexkey;
if (this.request.query.index_key) {
indexkey = config.env.APP_NAME.value +':'+ this.request.query.index_key;
} else {
indexkey = yield dbCo.get(config.env.APP_NAME.value +':current');
}
var index = yield dbCo.get(indexkey);
this.body = index || '';
});
app.listen(config.env.APP_PORT.value || 8787);