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

designer-news

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

designer-news

Designer News API client

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Designer News API

NodeJS client for accessing the Designer News API.

Installation

The library is available on npm:

npm install designer-news

Configuration

var DN = require('designer-news');

// Configure
var config = new DN.Configuration(function () {
  this.oauthKey = 'abc123'
  this.oauthSecret = 'foobar'

  // optional, if you have it
  this.accessToken = 'jfosdf9sud98fds0f8snd0fs8dnf'
});

// Create the client
var client = new DN.Client(config);

Usage

Authentication

// If configured without an access token, you will need
// to authenticate and retrieve one. Here's the password flow:
client.auth.withPassword('username', 'password', function (err, tokens) {
  // We are now logged in. The configuration is automatically updated
  // with the access token. We can store them somewhere persistent
  // if needed.
});

Retrieving Data

The JS function names roughly follow the same convention as the API URLs.

client.me(callback);

client.stories.get(id, callback);
client.stories.frontPage({page: 2}, callback);
client.stories.recent({page: 2}, callback);
client.stories.search(query, callback);
client.stories.upvote(id, callback);
client.stories.reply(id, comment, callback);

client.comments.get(id, callback);
client.comments.upvote(id, callback);
client.comments.reply(id, comment, callback);

client.motd.get(callback);
client.motd.upvote(callback);
client.motd.downvote(callback);

Promises

All asynchronous calls return a promise, which can be used as an alternative to providing a callback.

client.auth.withPassword('username', 'password').then(function (resp) {
  console.log(resp.accessToken);
  return client.stories.frontPage();
}).then(function (resp) {
  return client.stories.upvote(resp.stories[0].id);
}).then(function (story) {
  console.log(story);
});

Author

Ryan LeFevre - GitHub, Twitter, Email

License

Available under the MIT license. See the LICENSE file for more info.

Keywords

FAQs

Package last updated on 05 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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