-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
34 lines (27 loc) · 713 Bytes
/
main.js
File metadata and controls
34 lines (27 loc) · 713 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
31
32
33
34
import Koa from 'koa';
import serve from 'koa-static';
import send from 'koa-send';
import mount from 'koa-mount';
import Router from 'koa-router';
import ImdbSpider from './server/imdbSpider';
const app = new Koa();
const static_app = new Koa();
const router = new Router();
/*
bundle.js and style.css went in here
*/
static_app.use(serve('build'));
app.use(mount('/build', static_app));
/*
get movie or person based on uid
*/
router.get('/:id', async (ctx) => {
ctx.body = await ImdbSpider.go(ctx.params.id);
});
app.use(router.routes());
app.use(async(ctx) => {
await send(ctx, 'index.html');
});
app.listen(3000, () => {
console.log('VisualMovieInfo started at port 3000 ... enjoy!')
});