docs/index.html
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>endeavor</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.js" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">endeavor</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
<input type="checkbox" id="tsd-filter-only-exported" />
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="globals.html">Globals</a>
</li>
</ul>
<h1> endeavor</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<h1 id="endeavor">endeavor</h1>
<div align = "center">
<br>
<img src="./others/img/logo/logo.png" height=260>
<br>
<br>
<p><a href="https://saythanks.io/to/Fazendaaa"><img src="https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg?longCache=true&style=for-the-badge" alt="Say Thanks!"></a></p>
<p><a href="./README.md"><img src="https://img.shields.io/badge/Language-EN-blue.svg?longCache=true&style=for-the-badge" alt="English README"></a>
<a href="./docs/readme/README_PT.md"><img src="https://img.shields.io/badge/Linguagem-PT-green.svg?longCache=true&style=for-the-badge" alt="Portuguese README"></a></p>
<p><a href="https://travis-ci.org/Fazendaaa/endeavor"><img src="https://img.shields.io/travis/Fazendaaa/endeavor.svg?style=flat-square" alt="Build Status"></a>
<a href="https://codecov.io/gh/Fazendaaa/endeavor"><img src="https://img.shields.io/codecov/c/github/Fazendaaa/endeavor.svg?style=flat-square" alt="codecov"></a>
<a href="https://www.codacy.com/app/Fazendaaa/endeavor?utm_source=github.com&utm_medium=referral&utm_content=Fazendaaa/endeavor&utm_campaign=Badge_Grade"><img src="https://img.shields.io/codacy/grade/c07f1a46b4224191af8f94788013ed06/master.svg?style=flat-square" alt="Codacy Badge"></a>
<a href="https://www.npmjs.com/package/endeavor"><img src="https://img.shields.io/npm/dt/endeavor.svg?style=flat-square" alt="npm"></a>
<a href="https://codeclimate.com/github/Fazendaaa/endeavor/master/package.json"><img src="https://david-dm.org/Fazendaaa/endeavor.svg?style=flat-square" alt="Dependencies"></a>
<a href="https://snyk.io/test/github/Fazendaaa/endeavor"><img src="https://snyk.io/test/github/Fazendaaa/endeavor/badge.svg" alt="Known Vulnerabilities"></a>
<a href="https://codeclimate.com/github/Fazendaaa/endeavor/maintainability"><img src="https://api.codeclimate.com/v1/badges/5e7e7b6ec27b217a2013/maintainability" alt="Maintainability"></a></p>
</div>
<h2 id="about">About</h2>
<p>A <a href="https://nodejs.org/en/">node.js</a> package written in <a href="https://www.typescriptlang.org/">TypeScript</a>(TS) that consumes the <a href="https://github.com/AniList/ApiV2-GraphQL-Docs">Anilist API V2</a>, written to support <a href="https://graphql.org/">GraphQL</a> queries.</p>
<p>This package was written as dependency to <a href="https://telegram.org/">Telegram</a>'s <a href="https://fazendaaa.github.io/AnilistBot/">AnilistBot</a>.</p>
<h1 id="installing-it-">Installing it:</h1>
<pre><code class="language-bash">npm install --save endeavor</code></pre>
<p><strong>note</strong>: no need of installing <em>@types/endeavor</em> or something like it, the declaration typings file is linked in the <a href="./package.json">package.json</a>.</p>
<h1 id="how-to-use-it-">How to use it?</h1>
<p>Just use it as the following:</p>
<p><strong>queryAnilist({ query, variables })</strong></p>
<ul>
<li>Expect:<ul>
<li>[String] query: GraphQL query</li>
<li>[Object] variables?: if needed</li>
</ul>
</li>
<li>Returns a Promise:<ul>
<li>[Object] then: requested data</li>
<li>[Object | Error] catch: description error on the query or a Node error of the request</li>
</ul>
</li>
</ul>
<h2 id="examples">Examples</h2>
<pre><code class="language-js"><span class="hljs-keyword">const</span> query = <span class="hljs-string">'query ($id: Int) {\
Media (id: $id, type: ANIME) {\
id\
title {\
romaji\
english\
native\
}\
}\
}'</span>;
<span class="hljs-keyword">const</span> variables = {
<span class="hljs-attr">id</span>: <span class="hljs-number">15125</span>
};
<span class="hljs-keyword">const</span> result = queryAnilist({ query, variables }).then(<span class="hljs-built_in">console</span>.log);</code></pre>
<p>This will print the following:</p>
<pre><code class="language-js">data: {
<span class="hljs-attr">Media</span>: {
<span class="hljs-attr">id</span>: <span class="hljs-number">15125</span>,
<span class="hljs-attr">title</span>: {
<span class="hljs-attr">english</span>: <span class="hljs-string">'Teekyuu'</span>,
<span class="hljs-attr">native</span>: <span class="hljs-string">'てーきゅう'</span>,
<span class="hljs-attr">romaji</span>: <span class="hljs-string">'Teekyuu'</span>
}
}
}</code></pre>
<p>You can also use it as an <em>async</em> call encapsulating it as:</p>
<pre><code class="language-js"><span class="hljs-keyword">const</span> callAnilist = <span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> queryAnilist({ query, variables });
<span class="hljs-built_in">console</span>.log(result);
};</code></pre>
<p>This way, <strong>console.log</strong> also prints the same as before.</p>
<p>A more "advanced" usage of this package can be found at <a href="https://github.com/Fazendaaa/AnilistBot">AnilistBot</a>, with a caveat of a <a href="https://webpack.js.org/">webpack</a> due to <a href="https://github.com/samsarahq/graphql-loader">webpack-graphql-loader</a>.</p>
<h1 id="code">Code</h1>
<p>Plain and simple TS with the <a href="https://github.com/Microsoft/tslint-microsoft-contrib">Microsoft</a> linter standards.</p>
<h2 id="testing-it">Testing it</h2>
<p>Just run:</p>
<pre><code class="language-bash">npm <span class="hljs-built_in">test</span></code></pre>
<p>In case of running into a <a href="http://snyk.io/">Snyk</a> warning or something like that, just read their <a href="https://github.com/snyk/snyk#cli">docs</a> in how to solve it. If that is the case, jus run:</p>
<pre><code class="language-bash">npm run jest</code></pre>
<h2 id="built-with">Built with</h2>
<p>No dependency required :)</p>
<h1 id="todo">TODO</h1>
<ul>
<li>Mutation support</li>
<li>Write more examples</li>
</ul>
<h1 id="authors">Authors</h1>
<ul>
<li><a href="https://github.com/Fazendaaa">Fazendaaa</a></li>
</ul>
<h1 id="contributing">Contributing</h1>
<p>Talk to me through an issue.</p>
<h1 id="license">License</h1>
<p>Like many Open-Source Software (OSS) the MIT license is used, more about it in <a href="./LICENSE">LICENSE</a>.</p>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="globals ">
<a href="globals.html"><em>Globals</em></a>
</li>
<li class=" tsd-kind-external-module">
<a href="modules/_index_.html">"index"</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li>
<li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li>
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
<li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
<li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li>
<li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
<li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
<li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="http://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="assets/js/search.js"><' + '/script>');</script>
</body>
</html>