Git Product home page Git Product logo

esijs's Introduction


  ____ _              ___         _         __  

 / ___(_)_ __   __ _ / / | ____ _| | ___ _ _\ \ 

| |  _| | '_ \ / _` | || |/ / _` | |/ _ \ '__| |

| |_| | | | | | (_| | ||   < (_| | |  __/ |  | |

 \____|_|_| |_|\__, | ||_|\_\__,_| |\___|_|  | |

               |___/ \_\         |_|        /_/ 

You've visited my profile. Oh no.

uwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwu

About Me

species: unknown age: yes
location: wouldn't you like to know?

Bio (or something)

im a goofy fox, floating through space and stealing your garlic bread >:3
most of my repos are just random ideas i have, with some being useful like esiJS and cli-pride-flags
massive linux, bitcoin, and tech nerd, feel free to poke me with questions uwu

Links

My website is the main hub for my profile, check it out for a full bio
If you like my code, feel free to support me via btc lightning at [email protected] :3
For on-chain, check my site uwu

esijs's People

Contributors

cppctamber avatar dependabot[bot] avatar experibass avatar geekyaubergine avatar gingkathfox avatar jfcodes avatar karnthis avatar maxtsero avatar quantumferret avatar wmacomber avatar

Stargazers

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

Watchers

 avatar  avatar

esijs's Issues

README example instantiation doesn't work

In the READMe.md file, your sample code uses a zero-argument constructor for the esiJS class:

const esiJS = require('esijs')
const esiClient = new esiJS()

This generates a TypeError: Cannot read property 'logging' of undefined because you need to instantiate using something like:

const esiJS = require('esijs')
const esiClient = new esiJS({logging: false})

The sample code in the 'How To Install esiJS' wiki page is also wrong (and still has require('esiJS') too).

A few errors

Had a few immediate failures when pulling this in. Here they are (simple fixes?):

/node_modules/esijs/Functions/utility.js:24
        let path = 'latest v1 legacy dev'.split(' ')
            ^

SyntaxError: Identifier 'path' has already been declared

and

internal/modules/cjs/loader.js:797
    throw err;
    ^

Error: Cannot find module './Functions/killmails'
Require stack:
- /.../node_modules/esijs/endpoints.js
...

(node:26643) UnhandledPromiseRejectionWarning: ReferenceError: categoryID is not defined
Code seems to be taking the wrong input:

constellationInfo (constellationID) {
    inputValidation({ input: categoryID, type: 'number', message: `The function 'universe.constellations.constellationInfo requires a constellation Id!` })
    
    return request({ subUrl: `universe/constellations/${constellationID}` })
},

^ This one is fixed in this Pull Request: #8

killMails.js has incorrect casing in npm version

In endpoints.js, killMails.js is imported as killmails: require('./Functions/killMails'),. The version available on npm has the file kill mails cased as killmails.js resulting in not node/webpack being able to import the file. The file is correctly typed within the source code though which leads me to believe it is related to the build system used. As such I don't think I am able to fix this with a pr, what build system are you using?

[BUG] Caching causes issues with some requests

Some ESI requests have you pass data via a payload instead of like a URL parameter. From what I can tell, the caching system at the moment is based on a fullURL that is assembled here:

esiJS/src/util/util.js

Lines 158 to 178 in 890faf6

let fullURL = `${link}${subUrl}/?datasource=tranquility`
// If query params are defined, add them to the end of the full url
if (query) {
fullURL += `?${new URLSearchParams(query).toString()}` // URLSearchParams doesn't add the beginning "?"
}
// Add in the language
if (language !== '') {
fullURL += `&language=${language.split('/').join('-')}`
}
// and the auth token if needed
if (needsAuth && authToken !== '') {
// Include both the headers and the query just in case one or the other fails
headers['authorization'] = `Bearer ${authToken}`
fullURL += `&token=${authToken}`
} else if (needsAuth && authToken === '') {
throw buildError(`You used a authenicated function without a token. Please set a token in the 'esi.json' file in ${path.join(__dirname, '../../../')}.`, `NO_AUTH_TOKEN`)
}
// if the request isnt cached, send a request
if (!cache.has(fullURL)) {

Since that method doesn't account for payload parameters, it can cause the caching to return results from previous queries even though the parameters have changed.

The most blatant case of this that I have encountered thus far is with the universe.bulk.idsToNames endpoint as it takes an array of IDs as a payload. Making a second request before the cache times out causes it to return the previous results... which is incorrect.

Side note, my use case for this library is personal and I have explicit control over being respectful of ESI. So for my uses, I don't need a cache. As such I'm going to fork this library and modify it as needed for my own shenanigans. So this bug isn't a blocker for me personally, but I wanted to log it anyway.

[BUG] Alliance Corp List is setup wrong

The alliance group has an entry for corps that seems to be set up wrong.

esiJS/src/alliance.js

Lines 13 to 28 in bd6a725

/**
* Get all current member corporations of an alliance.
* @param ID {number} The alliance ID to get the alliances from.
* @returns {Promise<[number]>} The alliances in the alliance.
*/
corps(allianceID) {
inputValidation({
input: allianceID,
type: 'number',
message: `The function 'alliance.corps' requires an alliance ID!`
})
return request({
subUrl: `alliances/${allianceID}/alliances`
})
},

It is attempting to send a request to a alliances/${allianceID}/alliances endpoint which doesn't exist.

I believe this needs to be updated to point at the /alliances/${corporationID}/corporations/ ESI route instead.

[BUG] Corporation Alliance History is setup wrong

The corporation group has an entry for corporationHistory that seems to be set up wrong.

/**
* Get a list of all the aliances a corporation has been a member of.
* @param corporationID {number} The corporation to get the corporation history of.
* @returns {Promise<number[]>} A array of corporation IDs.
*/
corporationHistory(corporationID) {
inputValidation({
input: corporationID,
type: 'number',
message: `The function 'corporation.corporationHistory' requires a corporation ID!`
})
return request({
subUrl: `corporations/${corporationID}/corporationhistory`
})
},

The comment seems to acknowledge that this is meant to be for the corporation's alliance history, but it is named wrong and attempts to send a request to a corporations/${corporationID}/corporationhistory endpoint which doesn't exist.

I believe this may be a copy-paste error and needs to be updated to point at the /corporations/${corporationID}/alliancehistory/ ESI route instead.

Bug in README example?

I was trying out your library and I think I found a bug in the example.

The following resulted in "MODULE NOT FOUND".

const esiJS = require('esiJS')

Had to change it to:

const esiJS = require('esijs')

My platform is Ubuntu btw.

If you agree I can make a PR.

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.