Skip to content

Commit

Permalink
Changed response type header to json
Browse files Browse the repository at this point in the history
  • Loading branch information
crock committed Oct 13, 2018
1 parent ca403b6 commit d8046f0
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 12 deletions.
14 changes: 10 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ app.use(timeout('5s'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(haltOnTimedout);
app.use(function (req, res, next) {
res.header('Content-Type', 'application/json');
next();
});

function checkAuthKey(req, res, next) {
var keys = require('./apikeys.json');
Expand All @@ -44,16 +48,18 @@ router.get('/', function(req, res) {

router.get('/check/services', function(req, res) {
var simple = {"services":[]};
var advanced = require('./services.json');
var advanced = fs.readFileSync(path.join(__dirname, 'services.json'));
for (var key in advanced.services) {
simple.services.push(advanced.services[key].slug)
}
res.json(simple);
res.type('json');
res.json(200, simple);
});

router.get('/check/services/details', function(req, res) {
var obj = require('./services.json');
res.json(obj);
var json = fs.readFileSync(path.join(__dirname, 'services.json'));
res.type('json');
res.json(200, json);
});

router.get('/check/:service/:word', [cacheWithRedis('6 hours')], function(req, res) {
Expand Down
3 changes: 2 additions & 1 deletion libs/Instagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const axios = require('axios');
const faker = require('faker');

function CheckInstagram(service, word, res) {

res.type('json');

var token = "";
var mid = "";
var cookie = "";
Expand Down
7 changes: 4 additions & 3 deletions libs/Minecraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ const axios = require('axios');
const faker = require('faker');

function CheckMinecraft(service, word, res) {
res.type('json');

var url = `https://api.mojang.com/users/profiles/minecraft/${word}`;
var status = "";
var url = `https://api.mojang.com/users/profiles/minecraft/${word}`;
var status = "";

axios.get(url, null, { "headers": { "User-Agent": faker.internet.userAgent }})
axios.get(url, null, { "headers": { "User-Agent": faker.internet.userAgent }})
.then(results = (r) => {
var milliseconds = new Date().getTime();
try {
Expand Down
1 change: 1 addition & 0 deletions libs/Mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const router = express.Router();
const axios = require('axios');

function CheckMixer(service, word, res) {
res.type('json');

const url = `https://mixer.com/api/v1/channels/${word}`;

Expand Down
2 changes: 1 addition & 1 deletion libs/Steam.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const axios = require('axios');
const cheerio = require('cheerio');

function CheckSteam(service, word, res) {

res.type('json');
var url = "";

if (service == "steamid") {
Expand Down
2 changes: 1 addition & 1 deletion libs/Twitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const router = express.Router();
const twitch = require('twitch-api-v5');

function CheckTwitch(service, word, res) {

res.type('json');
var config = require('../configs/twitch.json');

twitch.clientID = config.clientId;
Expand Down
2 changes: 1 addition & 1 deletion libs/Twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const axios = require('axios');
const Twitter = require('twitter-lite');

function CheckTwitter(service, word, res) {

res.type('json');
var config = require('../configs/twitter.json');
var client = new Twitter(config);

Expand Down
2 changes: 1 addition & 1 deletion libs/Youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const router = express.Router();
const axios = require('axios');

function CheckYoutube(service, word, res) {

res.type('json');
const baseUrl = `https://www.youtube.com/${word}`;
const userUrl = `https://www.youtube.com/user/${word}`;
const chanUrl = `https://www.youtube.com/c/${word}`;
Expand Down

0 comments on commit d8046f0

Please sign in to comment.