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

moving to http #6

Merged
merged 13 commits into from
Jun 14, 2022
Merged

moving to http #6

merged 13 commits into from
Jun 14, 2022

Conversation

aldy505
Copy link
Member

@aldy505 aldy505 commented Jun 11, 2022

Closes #3

@aldy505 aldy505 requested review from elianiva and RayWP June 12, 2022 12:40
Copy link
Member

@elianiva elianiva left a 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/Error.ts Outdated Show resolved Hide resolved
rce/src/Error.ts Outdated Show resolved Hide resolved
rce/src/Error.ts Outdated Show resolved Hide resolved
rce/src/index.ts Outdated
Comment on lines 27 to 64
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"
})
);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pindahin ke module terpisah?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no?

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gapapalah

rce/src/index.ts Outdated Show resolved Hide resolved
rce/src/index.ts Show resolved Hide resolved
aldy505 and others added 5 commits June 12, 2022 22:16
Co-authored-by: elianiva <dicha.arkana03@gmail.com>
Co-authored-by: elianiva <dicha.arkana03@gmail.com>
Co-authored-by: elianiva <dicha.arkana03@gmail.com>
@aldy505 aldy505 requested a review from elianiva June 14, 2022 06:31
@aldy505 aldy505 merged commit d52f5e1 into master Jun 14, 2022
@aldy505 aldy505 deleted the feat/rce-http branch June 14, 2022 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate the rce module to HTTP instead of GRPC
2 participants