Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove req, res links spread. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix: remove req, res links spread.
There is no reason for giving links to a request and response object into `types.fucntion` scenario
georgolden authored Sep 4, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 4e986e58ab96793d31c35ab63b64a15a017af4bd
4 changes: 2 additions & 2 deletions JavaScript/goodServer.js
Original file line number Diff line number Diff line change
@@ -17,13 +17,13 @@ const types = {
object: JSON.stringify,
string: (s) => s,
undefined: () => 'not found',
function: (fn, req, res) => fn(req, res).toString(),
function: (fn) => fn().toString(),
};

http.createServer((req, res) => {
const data = routing[req.url];
const type = typeof data;
const serializer = types[type];
const result = serializer(data, req, res);
const result = serializer(data);
res.end(result);
}).listen(PORT);