Coder Social home page Coder Social logo

aknorw / discojs Goto Github PK

View Code? Open in Web Editor NEW
61.0 4.0 9.0 1.46 MB

Easiest way to use the Discogs API in Javascript/Typescript :musical_note:

Home Page: https://aknorw.github.io/discojs

License: MIT License

JavaScript 0.91% TypeScript 99.03% Shell 0.06%
discogs api client javascript typescript

discojs's Introduction

Discojs

Easiest way to use the Discogs API in Javascript - now with Typescript support! ๐ŸŽต

CircleCI Coverage Status

Installation

yarn add discojs

Usage example

import {Discojs} from 'discojs'

const client = new Discojs({
  userToken: process.env.USER_TOKEN,
})

client
  .searchArtist('Jacob Desvarieux')
  .then(data => doSomethingWith(data))

API Reference

v2

Documentation for [email protected] is available on GitHub Pages;

v1

Documentation for [email protected] is available in the wiki.

Tests

As several methods need authentication, you'll need 2 environment variables: DGS_USERNAME and USER_TOKEN.

Create a .env file at the root of the directory, and add the following lines:

DGS_USERNAME=0ctocat
USER_TOKEN=7h1515myu53r70k3n

โš ๏ธ Use a test account as public information will be edited.

As stated by Discogs API, some methods need a seller account. As I do not have one, I could not test them (which explains the coverage).

npm run test

When running tests, go grab a cup of coffee as this may be long because of Discogs API rate limiting.

Credits

Inspired by disconnect from @bartve

discojs's People

Contributors

aknorw avatar parrfolio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

discojs's Issues

Problems with core-js dependency

I got errors with the current version of core-js (v3.0.1) and had to install an old version (v2.6.5) to make discojs running.
Apparently there was some important changes between branch 2 and 3 of core-js, in particular core-js/modules/es6.promise disappeared which discojs rely upon.

v2 docs broken

Hi!!!

I'm in active development of using this library and it's been amazing so far! Very excited to upgrade to v2 soon, however it seems the link to the new docs are broken?

Discojs is not exported by default

Documentation has the import as follows:

  import Discojs  from "discojs";

but the above returns the following type error: TypeError: Discojs__default.default is not a constructor

current fix is to import the fn/constructor by name:

  import {Discojs}  from "discojs";

Discog images

Hiya,

Does this also allow access to artist profile images and release / master artwork ?

Can't use import

Hey,
When I use import in my file an error shows up cannot use import statement outside a module. I made some researches and I still don't really understand why I have this error. Can I use this without using import ?
Thanks

Build with webpack fails

I'm hitting a bug when i try to build an app with webpack that depends on discogs.

package.json

{
  "name": "discojs-webpack-test",
  "description": "test to build a webpack based app w/ discojs as dep.",
  "main": "index.js",
  "devDependencies": {
    "webpack": "^4.20.2",
    "webpack-cli": "^3.1.2"
  },
  "dependencies": {
    "discojs": "^1.0.1"
  }
}

src/index.js

import Discosjs from 'discojs'

const client = new Discosjs(
  {userToken: 'zohJeim3le9ooxahf9Dae9ae6YiacaoRaht3naiw'}
)

$ npm install && npm webpack

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN discojs-webpack-test@ No repository field.
npm WARN discojs-webpack-test@ No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 393 packages from 296 contributors and audited 4267 packages in 12.069s
found 0 vulnerabilities

Hash: 6a5a4ec6f11f17cf9139
Version: webpack 4.20.2
Time: 3831ms
Built at: 2018-10-14 23:35:41
  Asset      Size  Chunks             Chunk Names
main.js  89.8 KiB       0  [emitted]  main
Entrypoint main = main.js
 [6] ./src/index.js 121 bytes {0} [built]
 [8] (webpack)/buildin/global.js 509 bytes {0} [built]
[16] ./node_modules/bottleneck/lib sync 160 bytes {0} [built]
    + 20 hidden modules

WARNING in ./node_modules/bottleneck/lib/RedisStorage.js 89:14-91:10
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/bottleneck/lib/Bottleneck.js
 @ ./node_modules/bottleneck/lib/index.js
 @ ./node_modules/discojs/lib/index.js
 @ ./src/index.js

removeFromWantlist test returns NOT_FOUND

removeFromWantlist could return NOT_FOUND if the associated test is done before addToWantlist one.

Must edit the files to add the release in the wantlist before trying to remove it:

import chai from 'chai'

import Discojs from '../..'

// eslint-disable-next-line no-unused-vars
const should = chai.should()
let client

const releaseId = 1189932

describe('Users - Wantlist - removeFromWantlistMethod', () => {
  before(async () => {
    client = new Discojs({
      userToken: process.env.USER_TOKEN,
      requestLimitAuth: 20,
    })
    await client.addToWantlist({
      username: process.env.DGS_USERNAME,
      releaseId,
    })
  })
  it('should remove a release from a user\'s wantlist', async () => {
    const data = await client.removeFromWantlist(process.env.DGS_USERNAME, releaseId)
    data.should.be.an('object').and.have.property('statusCode')
    data.statusCode.should.be.equal(204)
  })
  it('should return a TypeError if no param', () => {
    client.removeFromWantlist().catch(err => err.should.be.an.instanceOf(TypeError))
  })
  it('should return a TypeError if `username` is not a string', () => {
    client.removeFromWantlist(1337).catch(err => err.should.be.an.instanceOf(TypeError))
  })
  it('should return a TypeError if `id` is not a number', () => {
    client.removeFromWantlist(process.env.DGS_USERNAME, 'test').catch(err => err.should.be.an.instanceOf(TypeError))
  })
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.