forked from f3arnil/backbone-spa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (27 loc) · 1006 Bytes
/
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
'use strict'
var express = require('express');
var config = require('./config.json');
var path = require('path');
var app = express();
var channels = require('./mock-data/channels.json');
var videos = require('./mock-data/videos.json');
var uiRootDir = path.join(__dirname + '/' + config.backbone.rootDirectory);
var bundlePath = __dirname + '/' + config.backbone.bundlePath;
var staticPath = __dirname + '/' + config.backbone.staticPath;
app.use('/build', express.static(bundlePath));
app.use('/static', express.static(staticPath));
app.get('/channels', function (req, res) {
res.send(channels);
});
app.get('/videos', function (req, res) {
res.send(videos);
});
app.listen(config.application.port, function () {
console.log('Example app listening on port ' + config.application.port + '!');
});
app.get('/', function (request, response) {
response.redirect('/tube-app');
});
app.get('/tube-app', function (req, res) {
res.sendFile(uiRootDir + '/app/tube-app/index.html');
});