Skip to content

Commit

Permalink
feat: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wopian committed Jun 29, 2017
1 parent 4b10468 commit 9917470
Show file tree
Hide file tree
Showing 13 changed files with 413 additions and 25 deletions.
20 changes: 20 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["> 1%", "last 2 versions"],
"node": 6
}
}],
"stage-0",
["babili", {
"mangle": false
}]
],
"plugins": [
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]
]
}
3 changes: 0 additions & 3 deletions .babelrc.yml

This file was deleted.

1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ node_js:
- node
- 7
- 6
- 5
cache:
yarn: true
sudo: false
Expand Down
99 changes: 99 additions & 0 deletions .yarnclean
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# test directories
__tests__
test
tests
powered-test
benchmarks

# asset directories
docs
doc
website
assets

# examples
example
examples

# code coverage directories
coverage
.nyc_output

# build scripts
Makefile
Gulpfile.js
Gruntfile.js

# configs
.tern-project
.gitattributes
.editorconfig
.*ignore
.eslintrc
.jshintrc
.flowconfig
.documentup.json
.yarn-metadata.json
.travis.yml
appveyor.yml
.appveyor.yml

# meta
changelog*
Changelog*
CHANGELOG*
license*
License*
LICENSE*
AUTHORS*

# misc
*.gz
*.obj
*.lib
*.exp
*.m4
*.3
*.info
*.texi
*.ac
*.in
*.tern-port
*.cc
*.c
*.s
*.py
*.pyc
*.pl
*.rb
*.tlog
*.sln
*.jshintrc
*.lint
*.eslintrc
*.editorconfig
*.npmignore
*.eslintignore
*.dntrc
*.cpp
*.jpg
*.gif
*.psd
*.bmp
*.jpeg
*.gitmodules
*.h
*.patch
*.md
*.txt
*.markdown
*.html
*.coffee
*.vcxproj
*.vcxproj.filters

# gyp
*.gypi
node-pre-gyp
node-gyp
gyp
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@

## [Unreleased]

## [0.1.0] - 2017-06-29

### Added

- GET requests for all models
- JSON API query parameters
- Authentication

[Unreleased]:https://github.com/wopian/kitsu/compare/28bbaaab4db4914f5fe18cd3a1c8ce2db9f3bb29...HEAD
[0.1.0]:https://github.com/wopian/kitsu/compare/28bbaaab4db4914f5fe18cd3a1c8ce2db9f3bb29...0.1.0
63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
[![CC Issues]][6]
[![David]][7]

NodeJS wrapper for [Kitsu.io][KITSU]
Promise based NodeJS API wrapper for [Kitsu.io][KITSU]

## Features

- Supports OAuth2 authentication
- Supports the JSON API specification
- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises) API
- Retries on network failure
- Timeout handling

## Install

```bash
Expand All @@ -27,13 +33,68 @@ npm install kitsu --save
## Usage

```javascript
// ES6+
import Kitsu from 'kitsu'
// CommonJS
const Kitsu = require('kitsu').default

const kitsu = new Kitsu()

kitsu.get('anime').then(res => console.log(res))
```

[More Examples](https://github.com/wopian/kitsu/tree/master/example)

## Docs

### kitsu.get(model, [options])

Returns a Promise of a `response` object

#### model

Type: `string`

The resource model to request. Check out the [Kitsu API documentation](https://docs.kitsu.apiary.io) for available models

#### options

Type: `object`

Any of the [JSON API](http://jsonapi.org/format/#fetching) request parameters

##### include

Type: `string`

Include relationships. Multiple includes are comma seperated

##### fields

Type: `object`

Returns only the specified fields

##### sort

Type: `string`

Sort lists by an attribute. Append `-` for descending order. Multiple sorts are comma seperated

##### page

Type: `object`

Limit number of returned resources (`page: { limit: 2 }`).

Offset returned resources (`page: { offset: 20 }`)

##### filter

Type: `object`

Filter returned resources by an attribute

## Contributing

### Requirements
Expand Down
16 changes: 16 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
environment:
matrix:
- nodejs_version: ""
- nodejs_version: "7"
- nodejs_version: "6"
platform:
- x64
- x86
cache:
- "%LOCALAPPDATA%\\Yarn"
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- yarn upgrade
test_script:
- yarn test
build: off
2 changes: 1 addition & 1 deletion example/basic.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Kitsu from '../src/main'
const Kitsu = require('../lib/kitsu').default

const kitsu = new Kitsu()

Expand Down
1 change: 1 addition & 0 deletions lib/kitsu.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/util/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "kitsu",
"version": "0.0.1",
"version": "0.1.0",
"description": "NodeJS wrapper for Kitsu.io's API",
"license": "MIT",
"author": "James Harris <wopian@wopian.me>",
"scripts": {
"test": "jest",
"start": "yarn run example:basic && yarn run example:async && yarn run example:auth",
"example:basic": "babel-node --presets env,stage-0 ./example/basic.js",
"example:async": "babel-node --presets env,stage-0 ./example/async.js",
"example:auth": "babel-node --presets env,stage-0 ./example/auth.js"
"build": "babel src -d lib",
"start": "yarn run example:basic",
"example:basic": "node ./example/basic",
"example:async": "babel-node ./example/async",
"example:auth": "babel-node ./example/auth"
},
"main": "lib/main.js",
"main": "lib/kitsu.js",
"repository": {
"type": "git",
"url": "https://github.com/wopian/kitsu.git"
Expand All @@ -21,14 +22,16 @@
},
"homepage": "https://github.com/wopian/kitsu#readme",
"dependencies": {
"camelcase": "^4.1.0",
"camelcase": "~4.1.0",
"client-oauth2": "~4.1.0",
"got": "~7.0.0"
},
"devDependencies": {
"babel-cli": "~6.24.1",
"babel-core": "~6.25.0",
"babel-eslint": "~7.2.3",
"babel-plugin-transform-runtime": "~6.23.0",
"babel-preset-babili": "~0.1.4",
"babel-preset-env": "~1.5.2",
"babel-preset-stage-0": "~6.24.1",
"eslint": "~4.1.1",
Expand Down
20 changes: 11 additions & 9 deletions src/main.js → src/kitsu.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ export default class Kitsu {
} : {
filter: { self: true }
})).data[0]
} else return {
errors: [
{
title: 'Not Logged In',
detail: 'No user is logged in',
code: 'K01',
status: 'K01'
}
]
} else {
return {
errors: [
{
title: 'Not Logged In',
detail: 'No user is logged in',
code: 'K01',
status: 'K01'
}
]
}
}
}

Expand Down
Loading

0 comments on commit 9917470

Please sign in to comment.