-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (31 loc) · 1.06 KB
/
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
39
40
41
42
var express = require('express'),
request = require('request'),
errorHandler = require('errorhandler'),
app = express(),
proxy = require('express-http-proxy');
var HOSTNAME = 'localhost',
PORT = 8090,
PUBLIC_DIR = __dirname + '/public_html';
var req_count = 0;
app.use(function (req, res, done) {
var date = new Date();
// Журналирование в формате [время] [номер запроса по счету]
console.log("[%s] [%d]", date.toTimeString(), req_count++);
done();
});
app
.use('/', express.static(PUBLIC_DIR))
.use(errorHandler())
/*.use('/api/*', function (req, res) {
var url = 'http://private-4133d4-technopark.apiary-mock.com' + req.originalUrl;
req.pipe(request(url)).pipe(res);
});*/
app.listen(PORT, function () {
console.log("Simple static server showing %s listening at http://%s:%s", PUBLIC_DIR, HOSTNAME, PORT);
});
app.use('/proxy', proxy('http://vk.com', {
forwardPath: function(req, res) {
console.log(1234);
return require('url').parse(req.url).path;
}
}));