-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major re-factoring
- Loading branch information
Showing
11 changed files
with
128 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Suggested API changes | ||
|
||
This would break the API so these features will not be upstreamed. | ||
|
||
## API: /check/services | ||
|
||
Having an extra object is kind of redundent, it would make more sense to just send a JSON array. | ||
|
||
For example: | ||
` | ||
[ | ||
"twitter", | ||
"instagram", | ||
"steamid", | ||
"steamgroup", | ||
"mixer", | ||
"youtube" | ||
] | ||
` | ||
|
||
DIFF: | ||
` | ||
- var simple = {"services": []}; | ||
+ var simple = []; | ||
var advanced = require('./services.json'); | ||
for (var key in advanced.services) { | ||
- simple.services.push(advanced.services[key].slug) | ||
+ simple.push(advanced.services[key].slug) | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const axios = require('axios'); | ||
|
||
function CheckMixer(service, word, res) { | ||
res.type('json'); | ||
|
||
const check = (word, callback) => { | ||
const url = `https://mixer.com/api/v1/channels/${word}`; | ||
|
||
var status = ""; | ||
|
||
axios.get(url).then(function (obj) { | ||
var milliseconds = new Date().getTime(); | ||
status = ('statusCode' in obj.data) ? "available" : "taken"; | ||
res.json({ service: service, username: word, status: status, timestamp: milliseconds }); | ||
callback(status, milliseconds) | ||
}).catch(function () { | ||
var milliseconds = new Date().getTime(); | ||
res.json({ service: service, username: word, status: "available", timestamp: milliseconds }); | ||
callback("available", milliseconds) | ||
}); | ||
} | ||
|
||
module.exports = CheckMixer; | ||
module.exports = check; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const axios = require('axios'); | ||
const cheerio = require('cheerio'); | ||
|
||
function CheckSteam(service, word, res) { | ||
res.type('json'); | ||
var url = ""; | ||
|
||
if (service == "steamid") { | ||
url = `https://steamcommunity.com/id/${word}`; | ||
} | ||
|
||
if (service == "steamgroup") { | ||
url = `https://steamcommunity.com/groups/${word}`; | ||
} | ||
const check = (word, callback) => { | ||
var url = `https://steamcommunity.com/id/${word}`; | ||
|
||
axios.get(url).then(function (response) { | ||
var $ = cheerio.load(response.data); | ||
var elem = $('body').find('h3').length; | ||
var milliseconds = new Date().getTime(); | ||
var status = (elem == 1) ? "available" : "taken"; | ||
res.json({ service: service, username: word, status: status, timestamp: milliseconds }); | ||
callback(status, milliseconds) | ||
}).catch(console.error); | ||
|
||
} | ||
|
||
module.exports = CheckSteam; | ||
module.exports = check; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const axios = require('axios'); | ||
const cheerio = require('cheerio'); | ||
|
||
const check = (word, callback) => { | ||
var url = `https://steamcommunity.com/groups/${word}`; | ||
|
||
axios.get(url).then(function (response) { | ||
var $ = cheerio.load(response.data); | ||
var elem = $('body').find('h3').length; | ||
var milliseconds = new Date().getTime(); | ||
var status = (elem == 1) ? "available" : "taken"; | ||
callback(status, milliseconds) | ||
}).catch(console.error); | ||
|
||
} | ||
|
||
module.exports = check; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.