Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
disconnect
Advanced tools
disconnect
is a Node.js client library that connects with the Discogs.com API v2.0.
function(err, data, rateLimit)
format for the callbackThe global structure of disconnect
looks as follows:
require('disconnect') -> new Client() -> database()
-> marketplace()
-> user() -> collection()
-> wantlist()
-> util
To get the user wantlist functions:
var Discogs = require('disconnect').Client;
var wantlist = new Discogs().user().wantlist();
More examples below.
Here are some basic usage examples that connect with the public API. Error handling has been left out for demonstrational purposes.
var Discogs = require('disconnect').Client;
Get release data.
app.get('/release/:id', function(req, res){
var db = new Discogs().database();
db.release(req.params.id, function(err, data){
res.send(data);
});
});
Set your own custom User-Agent. This is optional as when omitted disconnect
will set a default one with the value DisConnectClient/x.x.x
.
var dis = new Discogs('MyUserAgent/1.0');
Get page 2 of user's public collection showing 75 releases. The second param is the collection folder ID where 0 is always the "All" folder.
app.get('/collection/:user', function(req, res){
var col = new Discogs().user().collection();
col.releases(req.params.user, 0, {page:2, per_page:75}, function(err, data){
res.send(data);
});
});
Below are the steps that involve getting a valid OAuth access token from Discogs.
app.get('/authorize', function(req, res){
var dis = new Discogs();
dis.getRequestToken(
'CONSUMER_KEY',
'CONSUMER_SECRET',
'http://your-script-url/callback',
function(err, requestData){
// Persist "requestData" here so that the callback handler can
// access it later after returning from the authorize url
res.redirect(requestData.authorizeUrl);
}
);
});
After redirection to the Discogs authorize URL in step 1, authorize the application.
app.get('/callback', function(req, res){
var dis = new Discogs();
dis.getAccessToken(
requestData,
req.query.oauth_verifier, // Verification code sent back by Discogs
function(err, accessData){
// From this point on we no longer need "requestData", so it can be deleted.
// Persist "accessData" here for following OAuth calls
res.send('Received access token!');
}
);
});
Simply provide the constructor with the access data object persisted in step 3.
app.get('/identity', function(req, res){
var dis = new Discogs(accessData);
dis.identity(function(err, data){
res.send(data);
});
});
The User-Agent may still be passed for OAuth calls.
var dis = new Discogs('MyUserAgent/1.0', accessData);
Image requests require authentication and are subject to rate limiting.
app.get('/image/:filename', function(req, res){
var db = new Discogs(accessData).database(),
file = req.params.filename;
db.image(file, function(err, data, rateLimit){
// Data contains the raw binary image data
require('fs').writeFile(file, data, 'binary', function(err){
// See your current limits
console.log(rateLimit);
res.send('Image saved!');
});
});
});
MIT
FAQs
A full-featured Discogs API v2.0 client library
The npm package disconnect receives a total of 169 weekly downloads. As such, disconnect popularity was classified as not popular.
We found that disconnect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.