Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ If you want to have a compact layout, just you need to add `layout=compact` as a
| userID | Your StackOverflow userID | REQUIRED |
| theme | Theme of the StackOverflow card (light or dark) | light |
| layout | Layout of the StackOverflow card (compact or default) | default |
| site | [StackExchange network's](https://stackexchange.com/sites#questionsperday) site to generate your card | stackoverflow |

<br>

Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const StackOverflowCard = require('./src/StackOverflowCard');

http.createServer(async (req, res) => {
const reqURL = url.parse(req.url, true);
const { userID, theme = 'light', layout = 'default' } = reqURL.query;
const { userID, theme = 'light', layout = 'default', site = 'stackoverflow' } = reqURL.query;

if (!userID) {
res.write(JSON.stringify({error: 'Add your StackOverflow userID as query string'}));
res.end();
return;
}

const responseArticles = await fetch(`https://api.stackexchange.com/2.2/users/${userID}?site=stackoverflow&filter=!--1nZv)deGu1`);
const responseArticles = await fetch(`https://api.stackexchange.com/2.2/users/${userID}?site=${site}&filter=!--1nZv)deGu1`);
const json = await responseArticles.json();

if (!json.items || json.items.length === 0) {
Expand All @@ -32,5 +32,5 @@ http.createServer(async (req, res) => {
res.write(result);
res.end();
}).listen(process.env.PORT || 3000, function(){
console.log("server start at port 3000");
console.log("server start at port 3000");
});