Skip to content

Commit

Permalink
Clean logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ittechhunter committed Jun 5, 2024
1 parent 86b0c24 commit 67ee49e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4,331 deletions.
23 changes: 13 additions & 10 deletions lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ export function startDevServer(srcs: string[], dists: string[], devJsonPath: str
},
};

log.info(`Adding ${srcs} to already existing dev server...`);
const req = http.request(options, (res) => {
console.log(`STATUS: ${res.statusCode}`);
console.log(`HEADERS: ${JSON.stringify(res.headers)}`);

res.setEncoding('utf8');
let data = '';

Expand All @@ -56,12 +54,12 @@ export function startDevServer(srcs: string[], dists: string[], devJsonPath: str
});

res.on('end', () => {
console.log(`Response: ${data}`);
log.info(`${data}`);
});
});

req.on('error', (e) => {
console.log(`problem with request: ${e.message}`);
log.error(`problem with request: ${e.message}`);
});

// Write data to request body
Expand Down Expand Up @@ -122,16 +120,21 @@ export function createApp(devJsonPath: string, opts: DevOptions): Express.Applic
* Adds the loader json
*/
app.post("/api/apps", (req, res) => {
console.log(`Request: ${JSON.stringify(req.body)}`);
const srcs = req.body.srcs;
const dists = req.body.dists;
if (srcs.length != dists.length) {
log.info("Number of apps isn't coutable.");
return res.status(500).send("Error adding apps to dev server.");
}

log.info(`adding ${srcs} to watch list...`);
addApps(srcs, dists).then(() => {
res.status(200).send("Success");
log.info("New apps added successfully.");
res.status(200).send("New apps added successfully.");
}).catch((err: Error) => {
log.error(err.stack || err.message);
return res.status(500).send("Error reading redirect map.");
})
return res.status(500).send("Error adding apps to dev server.");
});
});

function proxyMiddleware(proxyUrl: string) {
Expand Down Expand Up @@ -191,7 +194,7 @@ export function createApp(devJsonPath: string, opts: DevOptions): Express.Applic

/**
* Proxy middleware for RPC requests
* @param proxyUrl
* @param proxyUrl
*/
app.all('/api/proxy-rpc', proxyMiddleware(RPC_URL[opts.network]));

Expand Down
1 change: 0 additions & 1 deletion tests/unit/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ describe("dev", () => {
const mockedGazeAdd = jest.spyOn(Gaze.prototype, 'add');

const mockHotOpts: DevOptions = { NoHot: true };
console.log("dev", dev);
await dev(mockSrc, mockHotOpts);

const mockSrc2 = "/app_example_2";
Expand Down
Loading

0 comments on commit 67ee49e

Please sign in to comment.