-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
60 lines (51 loc) · 1.34 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
var bodyParser = require("body-parser");
var errorHandler = require("errorhandler");
var express = require("express");
var path = require("path");
var yargs = require("yargs");
module.exports = function(options, callback) {
var app = express();
app.use(bodyParser.json());
require("./project").init(options, app);
require("./asset").init(options, app);
app.use(express.static(__dirname + "/public"));
app.use(errorHandler());
return callback(null, app);
};
if (require.main === module) {
var options = yargs
.option("d", {
alias: "data",
default: path.resolve(__dirname, "data"),
describe: "Data repertory",
})
.option("e", {
alias: "export",
default: path.resolve(__dirname, "export"),
describe: "Export repertory",
})
.option("g", {
alias: "git",
default: false,
describe: "Commit changes automatically",
})
.option("p", {
alias: "port",
default: process.env.PORT || 8084,
describe: "Port to listen to",
})
.option("t", {
alias: "templates",
default: path.resolve(__dirname, "data_templates"),
describe: "Data templates repertory",
})
.help("help")
.alias("h", "help")
.argv;
module.exports(options, function(err, app) {
if (err) throw err;
app.listen(options.port, function() {
console.log("Server listening on port %d in mode %s.", options.port, app.get("env"));
});
});
}