-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
38 lines (28 loc) · 954 Bytes
/
server.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
'use strict';
var jsx = require('node-jsx');
jsx.install();
var express = require('express');
var ejs = require('ejs');
var React = require('react');
var loadPopularAction = require('./src/actions/loadPopular.action');
var MediaStore = require('./src/stores/media.store');
var MediaList = require('./src/components/list.component.jsx');
var app = express();
app.use(require('connect-livereload')());
app.set('view engine', 'ejs');
app.use(express.static('./node_modules'));
app.use(express.static('./dist'));
app.use(express.static('./src'));
app.get('/', function (req, res) {
loadPopularAction(function () {
var markup = React.renderToString(React.createElement(MediaList));
var mediaStoreData = 'var ISO_DATA = ' + JSON.stringify(MediaStore.getMedia()) + ';';
res.render('index', {
markup: markup,
mediaStoreData: mediaStoreData
});
});
});
app.listen(3000, function () {
console.log('Server started');
});