-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
28 lines (27 loc) · 883 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
var path = require('path');
var fs = require('fs');
var express = require('express');
var argv = require('yargs').argv;
var config = require('./shark-automation-config.js');
var app = express();
var webappDir = 'build/';
//html
app.use(config.contextPath, express.static(path.join(webappDir, 'app')));
//mimg
app.use(config.contextPath, express.static(path.join(webappDir, 'mimg')));
//ajax mock
app.use(config.contextPath + config.ajaxPrefix, function (req, res) {
var data = path.join(config.rootPath, config.mock, config.ajaxPrefix, req.path);
if (fs.existsSync(data)) {
res.send(fs.readFileSync(data));
} else {
res.status(404).send('file not exist !');
}
});
var port = argv.port || config.browserPort;
app.listen(port, function (err) {
if (err) {
return console.log(err);
}
console.log('express listening on %d', port);
});