-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathapp.js
executable file
·41 lines (33 loc) · 1.06 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
var express = require('express');
var fs = require('fs');
var http = require("http");
var promise = require('bluebird');
var mkdirp = promise.promisify(require('mkdirp'));
var env = process.env.NODE_ENV || 'development';
var bodyParser = require('body-parser');
/* ---------------- Server Controller ------------------*/
var editorCtrl = require('./server/editor');
function Server(){
this.app = express();
this.start = function(){
http.createServer(this.app).listen(process.env.PORT || 3000);
console.log('Onlive video editor is Running successfully on environment : '+env);
};
this.routingSetUp = function(){
editorCtrl(this.app);
};
this.setupExpressMiddleware = function(){
var dir = __dirname + '/videos';
if (!fs.existsSync(dir))
fs.mkdirSync(dir);
this.app.use(express.static(dir));
};
this.exportsApp = function(){
exports = module.exports = this.app;
};
}
var server = new Server();
server.start();
server.setupExpressMiddleware();
server.routingSetUp();
server.exportsApp();