Comparing version 0.0.1 to 0.1.0
21
index.js
var request = require('request'); | ||
var baseUrl = "https://api.4chan.org"; | ||
var baseUrl = "https://a.4cdn.org"; | ||
var api = {}; | ||
var requestOptions = { | ||
json:true, | ||
headers: { | ||
'if-modified-since': (new Date()).toUTCString() | ||
} | ||
}; | ||
api.boards = function(cb) { | ||
var uri = [baseUrl, "boards.json"].join("/"); | ||
request(uri, {json:true}, function(err, res, body){ | ||
request(uri, requestOptions, function(err, res, body){ | ||
if (err) return cb(err); | ||
@@ -22,3 +29,3 @@ cb(null, body.boards); | ||
subapi.image = function(file) { | ||
return ["https://images.4chan.org/", board, "src", file].join("/"); | ||
return ["https://i.4cdn.org", board, "src", file].join("/"); | ||
}; | ||
@@ -29,3 +36,3 @@ | ||
request(uri, {json:true}, function(err, res, body){ | ||
request(uri, requestOptions, function(err, res, body){ | ||
if (err) return cb(err); | ||
@@ -41,3 +48,3 @@ cb(null, body); | ||
request(uri, {json:true}, function(err, res, body){ | ||
request(uri, requestOptions, function(err, res, body){ | ||
if (err) return cb(err); | ||
@@ -53,3 +60,3 @@ cb(null, body); | ||
request(uri, {json:true}, function(err, res, body){ | ||
request(uri, requestOptions, function(err, res, body){ | ||
if (err) return cb(err); | ||
@@ -65,3 +72,3 @@ cb(null, body.threads); | ||
request(uri, {json:true}, function(err, res, body){ | ||
request(uri, requestOptions, function(err, res, body){ | ||
if (err) return cb(err); | ||
@@ -68,0 +75,0 @@ cb(null, body.posts); |
{ | ||
"name":"4chanjs", | ||
"description":"NodeJS and Browser 4chan API client", | ||
"version":"0.0.1", | ||
"version":"0.1.0", | ||
"homepage":"http://github.com/wearefractal/4chanjs", | ||
@@ -6,0 +6,0 @@ "repository":"git://github.com/wearefractal/4chanjs.git", |
@@ -24,9 +24,9 @@ [![Build Status](https://travis-ci.org/wearefractal/4chanjs.png?branch=master)](https://travis-ci.org/wearefractal/4chanjs) | ||
```javascript | ||
var 4chan = require('4chanjs'); | ||
var chan = require('4chanjs'); | ||
4chan.boards(function(err, boards){ | ||
chan.boards(function(err, boards){ | ||
// boards is an array | ||
}); | ||
var random = 4chan.board('b'); | ||
var random = chan.board('b'); | ||
@@ -33,0 +33,0 @@ random.catalog(function(err, pages){ |
8255
141