Commit b92a8ba0 authored by nanahira's avatar nanahira

update

parent f3d997d4
FROM node
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN npm ci
RUN npm install
CMD node index.js 443
......@@ -19,7 +19,7 @@ const https_server = https.createServer(https_options, (request, response) => {
}
const username = path_match[1];
_request({
url: "https://ygobbs.com/users/" + username + ".json",
url: "https://ygobbs.com/users/" + encodeURIComponent(username) + ".json",
json: true
}, (error, res, body) => {
if (error) {
......@@ -31,12 +31,17 @@ const https_server = https.createServer(https_options, (request, response) => {
response.end("Bad username JSON.");
console.log("BAD USERNAME JSON", body);
} else if (!body.users) {
response.writeHead(404);
response.end("User not found.");
request_avatar(username);
} else {
const real_username = encodeURIComponent(body.users[0].username);
const real_username = body.users[0].username;
request_avatar(real_username);
}
});
});
function request_avatar(response, username) {
_request({
url: "https://api.moecube.com/accounts/users/" + real_username + ".avatar"
url: "https://api.moecube.com/accounts/users/" + encodeURIComponent(username) + ".avatar"
}, (error, res, body) => {
if (error) {
response.writeHead(500);
......@@ -64,8 +69,6 @@ const https_server = https.createServer(https_options, (request, response) => {
});
}
});
}
});
});
}
https_server.listen(parseInt(process.argv[2]));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment