-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
moving to http #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ini udah bisa jalan belum sih wkwkwk
mau nyoba sendiri tapi, ya gitu lah
rce/src/index.ts
Outdated
server.use(async (req, res, next) => { | ||
try { | ||
let body = ""; | ||
|
||
for await (const chunk of req) { | ||
body += chunk; | ||
} | ||
console.log("Server started"); | ||
server.start(); | ||
|
||
switch (req.headers["content-type"]) { | ||
case "application/x-www-form-urlencoded": { | ||
const url = new URLSearchParams(body); | ||
req.body = Object.fromEntries(url.entries()); | ||
break; | ||
} | ||
case "application/json": | ||
default: | ||
req.body = JSON.parse(body); | ||
} | ||
next(); | ||
} catch (error) { | ||
switch (req.headers["content-type"]) { | ||
case "application/x-www-form-urlencoded": { | ||
res.writeHead(400, { "Content-Type": "application/x-www-form-urlencoded" }).end( | ||
new URLSearchParams({ | ||
msg: "Invalid body content with the Content-Type header specification" | ||
}).toString() | ||
); | ||
break; | ||
} | ||
case "application/json": | ||
default: | ||
res.writeHead(400, { "Content-Type": "application/json" }).end( | ||
JSON.stringify({ | ||
msg: "Invalid body content with the Content-Type header specification" | ||
}) | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pindahin ke module terpisah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rada nganu sih lihat body parser numpuk disini
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gapapalah
Co-authored-by: elianiva <dicha.arkana03@gmail.com>
Co-authored-by: elianiva <dicha.arkana03@gmail.com>
Co-authored-by: elianiva <dicha.arkana03@gmail.com>
feat: new rce packages
Closes #3