-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (27 loc) · 1.03 KB
/
index.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
// referenced by https://github.com/expressjs/express/blob/e1b45ebd050b6f06aa38cda5aaf0c21708b0c71e/lib/application.js
// and https://github.com/mysqljs/mysql/blob/master/lib/Connection.js
const app = require('express').application;
const mysql = require('mysql');
const http = require('http');
const res = require('express').response;
mysql.originalCreateConnection = mysql.createConnection;
res.originalRedirect = res.redirect;
// app.listen
app.listen = function listen(port) {
var server = http.createServer(this);
return server.listen.apply(server, [3000]);
};
// createConnection overwrite
mysql.createConnection = function createConnection(config) {
var _this = this;
if (process.env.IDENTIFIER === 'ANSWER'){
config.database = 'answer_' + config.database;
}
return mysql.originalCreateConnection.call(_this, config);
}
// res.redirect overwrite
res.redirect = function redirect(url) {
var _this = this;
new_url = url + "?containerPort=3000&languageName=nodejs";
return res.originalRedirect.call(_this, new_url);
};