Skip to content

Commit 03bae50

Browse files
authored
feat: expose middleware for dist usage (#113)
* chore: add debug for wednesday Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * chore: add debug for wednesday Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * chore: add khook in register Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * chore: add khook in register Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * chore: add khook in register Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * chore: add khook in register Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * chore: add khook in register Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * refactor: add support for normal middleware Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> --------- Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com>
1 parent 40f10a0 commit 03bae50

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

v2/dedup/middleware.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function afterMiddleware(req: Request, res: Response) {
8080
let count = 0;
8181
const executedLinebyEachTest = new Array();
8282
function GetCoverage() {
83-
console.log("Inside GetCoverage");
83+
console.log("Calculating per request coverage...");
8484
count++;
8585
let executedLinesByFile = {};
8686
// iterate over global.__coverage__
@@ -123,8 +123,10 @@ function GetCoverage() {
123123
// @ts-ignore
124124
executedLinebyEachTest.push({ ...hitCounts });
125125

126-
console.log("Executed lines by file:", executedLinesByFile);
126+
// console.log("Executed lines by file:", executedLinesByFile);
127127
// extract s from the coverage data
128128
}
129129
return executedLinesByFile;
130130
}
131+
132+
module.exports = middleware;

v2/dedup/register.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import Hook from "require-in-the-middle";
33
import expressMiddleware from "./middleware";
44
import bodyParser from "body-parser";
55
import cors from "cors";
6-
// import mixin from "merge-descriptors";
7-
const _ = require('lodash');
86

7+
const _ = require('lodash');
8+
const khook = "keployWrappedExpress";
99
// @ts-ignore
1010
Hook(["express"], function (exports) {
11+
// console.log("Inside keploy hook...");
1112
const expressApp = exports;
1213
function keployWrappedExpress() {
1314
const keployApp = expressApp();
@@ -18,12 +19,12 @@ Hook(["express"], function (exports) {
1819
keployApp.appliedMiddleware = true;
1920
return keployApp;
2021
}
21-
22+
2223
// copy the properties and methods of exported Function object into wrapped Funtion(keployWrappedExpress).
2324
// In order to prevent "express._Method_ or express._Field_ is not declared" error.
2425
// mixin(keployWrappedExpress, expressApp, false);
2526
_.assign(keployWrappedExpress, expressApp);
2627
exports = keployWrappedExpress;
2728
return exports;
2829
});
29-
export { };
30+
export { khook };

0 commit comments

Comments
 (0)