Code Monkey home page Code Monkey logo

oba-wrapper's Introduction

Hi there ๐Ÿ‘‹

// About me

type Idea = Readonly<{
  concreteEnough: boolean;
  meetsExpectations: boolean;
}>;

const brainstorm = (subject: Inspiration | Promise<Idea>): Promise<Idea> =>
  sketchOut(subject);

const design = (idea: Promise<Idea>): Promise<Design> =>
  (idea.concreteEnough && idea.meetsExpectations)
    ? makeMockups(idea)
    : design(brainstorm(idea));

const develop = (design: Promise<Design>): Promise<Implementation> =>
  vsCode(design);

const wouter = (inspiration: Inspiration) =>
  develop(design(brainstorm(inspiration)));
Have a look at my projects.

โš  WARNING: Cool stuff ahead.

oba-wrapper's People

Contributors

maanlamp avatar

Stargazers

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

Watchers

 avatar

Forkers

roobinh maybuzz

oba-wrapper's Issues

Keep the readme simple

The readme right now is kinda scary. There are a lot of complex code examples, and the glossary is gigantic. Instead, consider only showing the barebones installation instructions and description in the main readme, and moving the reference and full docs into a separate file or the repo wiki.

Example simple readme:


OBA API SDK

Small wrapper library that makes it easier to work with the OBA API.

Installation

npm install @maanlamp/oba-sdk

Usage

import SDK from "@maanlamp/oba-sdk";

const client = new sdk({
  key: "abcdef123456"
});

client.search("banaan")
  .then(console.log)
  .catch(console.error);

Full SDK Docs

Team

@maanlamp ๐ŸŒœ๐Ÿ’ก

License

MIT etc etc

Can't use /availability endpoint

I found a few things that prevent the /availability endpoint from working with the wrapper.

ID not working

An id for this endpoint would look like this |oba-catalogus|1201384, the problem however is that the | gets parsed to %7C which causes an error.

OBA-wrapper/js/index.js

Lines 45 to 48 in 4833006

switch (endpoint) {
case "search": return "q";
case "details": //fallthrough
case "availability": return "id";

Changing id in the code above to frabl works, because the frabl doesn't use special characters.

Unknown parameters

&pagesize=1&refine=false are given to any built url by default. But those parameters aren't known by the /availability endpoint, so it causes an error.

OBA-wrapper/js/index.js

Lines 83 to 85 in 4833006

const builtURL = (context !== null)
? url + `&pagesize=1&refine=false&rctx=${context}`
: url + `&pagesize=1&refine=false`;

I would suggest checking what endpoint is used and applying those parameters accordingly.

Sidenote: why are you setting refine=false on every normal /search? I thought refine=true returned extra info about the search results.

Supressed TypeError: Cannot read property '_text' of undefined

When I manually fixed (in a very dirty way, which breaks /search) the above issues I got a Supressed TypeError: Cannot read property '_text' of undefined

export function buildPong (json) {
return new Pong(
Number(json.aquabrowser.meta.count._text),
String(json.aquabrowser.meta.rctx._text));
}

I believe it fails because json.aquabrowser.meta.count doesn't exist in the response of the /availability endpoint.

Overengineering

Hi there!

While I'm quite impressed by the technical prowess of this package, aren't some of the methods a bit over-engineered?

For example, the most basic usage of this package is (as per the readme)

(async () => {
  localStorage.clear();

  const api = new API({
      key: "ADD YOUR KEY HERE"
  });
  const stream = await api.createStream("search/banaan{5}");

  stream
    .pipe(stringify)
    .pipe(console.log)
    .catch(console.error);
})();

however, I feel like the (internal package) API could be way simpler by using a syntax like:

const api = new API({ key: "" });

api.search("banaan")
  .then(console.log)
  .catch(console.error);

you could then provide method shorthands for the available endpoints:

/search
/details
/refine
/schema
/index
/availability
/holdings
/resolver

Again, great job on all the fancy features! I'm a big fan of experimenting with these kind of things, and the minor is the perfect time to do it. I would be the last person to argue otherwise.

That being said, in a real-life use scenario, you don't need all the fancy options. I would even argue that it adds a whole lot of confusion for new users while it doesn't add much in terms of benefits.

Is this true?

has a public API that is usable by everyone to create very cool stuff;

The OBA API requires an authentication key that I can't seem to get in any way ๐Ÿ‘€

Now that I think about it, maybe you can add a note to the readme on how to retrieve an access key.

Publish the test.html doc on GitHub Pages

It would be incredibly useful to be able to play around with the demo test.html file without having to clone and install everything. You could keep a separate branch for this live demo or publish the whole master branch and add a link to the repo.

Make localStorage configurable

One of the reasons this package is browser only right now is the fact that it uses localStorage. Please consider making the storage engine configurable.

const api = new API({
  storage: window.localStorage
});

This allows the user to switch out localStorage for any storage engine or package that uses the same getItem and setItem syntax, like sessionStorage or even flavors of a memory or document store in Node!

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.