This repository has been archived by the owner on Apr 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
63 lines (54 loc) · 1.61 KB
/
app.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
import Koa from 'koa'
import views from 'koa-views'
import serve from 'koa-static'
import bodyParser from 'koa-bodyparser'
import apiRoutes from './applications/api/routes/index'
import siteRoutes from './applications/site/routes/index'
import Tweet from './models/tweet'
import session from "koa-session2";
import redis from './configs/redis';
import userAgent from 'koa2-useragent';
import co from 'co';
import render from 'koa-ejs';
const app = new Koa();
/**
* Template for instagram
*
*/
// var InstagramPosts, streamOfPosts;
// InstagramPosts = require('instagram-screen-scrape').InstagramPosts;
//
// streamOfPosts = new InstagramPosts({
// username: 'greenlool'
// });
//
// streamOfPosts.on('data', function(post) {
// var time = new Date(post.time * 1000);
// console.log([
// "greenlool's post from ",
// time.toLocaleDateString(),
// " got ",
// post.likes,
// " like(s), and ",
// post.comments,
// " comment(s)",
// "media: ",
// post.media
// ].join(''));
// });
app.use(userAgent());
app.use(async (ctx, next) => {
// console.log(ctx.userAgent.version);
await next();
});
//app.use(convert(require('koa-static')(__dirname + '/public')));
app.use(serve(`${__dirname}/public`));
app.use(views(`${__dirname}/views`, { extension: 'ejs' }));
//app.use(mount('/static', serve('public')));
app.use(bodyParser());
app.use(apiRoutes.routes());
app.use(siteRoutes.routes());
app.listen(3000, () => {
console.log('Server running at http://localhost:3000');
});
export default app