New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hacka-news

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hacka-news - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

.travis.yml

10

package.json
{
"name": "hacka-news",
"version": "1.1.0",
"version": "1.2.0",
"description": "npm module for loading and organizing content from the official Hacker News API.",

@@ -10,3 +10,3 @@ "main": "src/hacka-news.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},

@@ -34,4 +34,8 @@ "repository": {

"engines": {
"node" : ">=4.0.0"
"node": ">=4.0.0"
},
"devDependencies": {
"mocha": "^2.4.5",
"should": "^8.3.1"
}
}

@@ -1,2 +0,2 @@

# hacka-news
# hacka-news [![Build Status](https://travis-ci.org/Coteh/hacka-news.svg?branch=master)](https://travis-ci.org/Coteh/hacka-news)
-----------------

@@ -11,7 +11,20 @@ A node module that utilizes the [Hacker News](https://news.ycombinator.com/) [official API](https://github.com/HackerNews/API) and powers [my command line app (of similar name)](https://github.com/Coteh/hacka-news-cli).

## Installation
Run *git clone hacka-news* to clone this repository, then run *npm install* to install all the dependencies.
Clone the repository with:
`git clone https://github.com/Coteh/hacka-news`
Then to install all the dependencies, run:
`npm install`
## Testing
Currently, the tests are set up using the [mocha](http://mochajs.org/) testing framework, and assertions done using [should](https://www.npmjs.com/package/should).
To run the tests, make sure you have mocha installed globally using:
`npm install -g mocha`
Then run the tests using:
`mocha`
## Issues
- Error comments are unorganized
- No unit/integration testing
- No integration testing

@@ -18,0 +31,0 @@ ## Future Additions

var request = require('request');
var hackaTime = require('./hacka-time');
var HACKA_URL = "https://news.ycombinator.com/";
var MAX_LIST_STORIES = 500; //The official HN API only stores up to 500 top/new stories
const MAX_LIST_STORIES = 500; //The official HN API only provides 500 top/new stories
const MAX_POSTINGS_STORIES = 200; //The official HN API only provides 200 ask/show/job stories
var hackaAPIURL = "https://hacker-news.firebaseio.com/v0/";
var amtOfFeedStories = 10;
var jsonObject = null;
var getAmountOfFeedStories = function(){
return amtOfFeedStories;
};
var getURL = function(id){

@@ -22,3 +19,8 @@ return HACKA_URL + "item?id=" + id;

var requestFeedStoryIDs = function(storyType, callback){
var pruneResults = function(ids, limit){
var prunedIDs = ids.slice(0, limit);
return prunedIDs;
}
var requestFeedStoryIDs = function(storyType, limit, callback){
request(hackaAPIURL + storyType + "stories.json?print=pretty", function(error, response, body) {

@@ -30,2 +32,6 @@ if (error){

ids = JSON.parse(body);
var maxLimit = (storyType == "top" || storyType == "new") ? MAX_LIST_STORIES : MAX_POSTINGS_STORIES;
if (limit < maxLimit) {
ids = pruneResults(ids, limit);
}
callback(ids);

@@ -37,3 +43,3 @@ });

request(hackaAPIURL + "item/" + id + ".json?print=pretty", function (error, response, body) {
if (error){
if (error || body === "null\n"){
console.log("ERROR: Couldn't load story.");

@@ -46,5 +52,9 @@ return;

var parseStory = function(jsonStr){
return JSON.parse(jsonStr);
}
var requestStoryParsed = function(id, callback){
requestStory(id, function(hnJsonStr){
var parsedStory = JSON.parse(hnJsonStr);
var parsedStory = parseStory(hnJsonStr);
injectStoryExtras(parsedStory, callback);

@@ -127,3 +137,3 @@ // callback(parsedStory);

}
requestFeedStoryIDs("top", function(ids){
requestFeedStoryIDs("top", 1, function(ids){
if (ids == null){

@@ -144,3 +154,2 @@ console.log("ERROR: Top stories did not load.");

module.exports = {
getAmountOfFeedStories,
getURL,

@@ -150,3 +159,7 @@ setAPIURL,

requestStory,
parseStory,
requestStoryParsed,
injectStoryExtras,
requestRootParent,
requestPollOptions,
requestGroup,

@@ -156,1 +169,3 @@ fetchTopID,

};
module.exports.time = hackaTime;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc