Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/laughedelic/scalajs-octokit

:octocat: Scala.js facades for octokit/rest.js (GitHub REST API v3)
https://github.com/laughedelic/scalajs-octokit

api-client github-api github-rest-v3 octokit octokit-js rest rest-api scala scala-js scalajs scalajs-facade

Last synced: 9 days ago
JSON representation

:octocat: Scala.js facades for octokit/rest.js (GitHub REST API v3)

Awesome Lists containing this project

README

        

# [Scala.js] facades for [octokit/rest.js]

[](https://www.npmjs.com/package/@octokit/rest/v/15.8.0)
[](https://www.scala-js.org)
[![](https://travis-ci.com/laughedelic/scalajs-octokit.svg?branch=master)](https://travis-ci.com/laughedelic/scalajs-octokit)
[![](http://img.shields.io/github/release/laughedelic/scalajs-octokit/all.svg)](https://github.com/laughedelic/scalajs-octokit/releases/latest)
[![](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://www.tldrlegal.com/l/mpl-2.0)
[![](https://img.shields.io/badge/contact-gitter_chat-dd1054.svg)](https://gitter.im/laughedelic/scalajs-octokit)

This project contains Scala.js facades for [octokit/rest.js], the official GitHub REST API v3 client for Node.js.

## 🚧 WORK IN PROGRESS 🚧

_This project is in active development, there are no published releases yet. Things may break without a warning, so don't rely on it._

## Usage

### Installation

🛠 Check installation instructions later, when there is a published release...

1. Add Octokit dependency to your project. It's important that the version of the underlying JS library matches the one this facade is built for.

* If it's a Node.js project where you manage dependencies with npm, run
```shell
npm install @octokit/[email protected]
```

* If it's a Scala.js project use [scalajs-bundler] and add to your `build.sbt`:
```scala
Compile/npmDependencies += "@octokit/rest" -> "15.8.0"
```

2. Add facades dependency to your `build.sbt`:
```scala
resolvers += Resolver.jcenterRepo
libraryDependencies += "laughedelic" %%% "scalajs-octokit" % ""
```
(see the latest release version on the badge above)

### Example

Here's a simple usage example:

```scala
import laughedelic.octokit.rest._

// Non-authenticated client with default parameters:
val octokit = new Octokit()

// A simple request (returns a Future)
octokit.repos.get(
owner = "octokit",
repo = "rest.js"
).foreach { response =>

// Check some data in the response
println(response.data.full_name)
println(response.data.stargazers_count)
println(response.data.license.name)

// Or print the whole payload (see https://developer.github.com/v3/repos/#get)
println(js.JSON.stringify(response.data, space = 2))
}
```

## Project structure

Most of the code in this project is generated, so you won't find it in the repository. To see that code you need to clone the project and run `sbt compile`.

The code that parses `routes.json` and generates the Scala code is in `project/src/`, so it's available to the main build and is used in the `sourceGenerators`.

There is also some manually written code: [`src/main/scala/octokit.scala`](src/main/scala/octokit.scala). It defines types for the `Octokit` client, its options, authentication and pagination.

## Documentation

There's no documentation in the project (yet), but you may find useful these resources:
* octokit/rest.js [readme](https://github.com/octokit/rest.js#restjs) and [API docs](https://octokit.github.io/rest.js)
* GitHub [REST API v3 docs](https://developer.github.com/v3)

## Related projects

* [scalajs-io/github-api-node](https://github.com/scalajs-io/github-api-node): partial facade for the [Github.js](http://github-tools.github.io/github) library
> Github.js provides a minimal higher-level wrapper around Github's API

* [47deg/github4s](http://47deg.github.io/github4s): JVM/JS-compatible Scala wrapper for (a part of) the GitHub API
> Github4s is based on a Free Monad Architecture, which helps decoupling of program declaration from program interpretation

#### How is this project different

* This is a Scala.js-only ([facades](https://www.scala-js.org/doc/interoperability/facade-types.html)) library, no JVM
* It builds on the official JS client for node which covers _all available GitHub REST API v3_ (including latest previews)
* The code is automatically generated using the same source as the underlying JS library, which means it should be easy to maintain and keep in sync

[Scala.js]: https://www.scala-js.org
[octokit/rest.js]: https://github.com/octokit/rest.js
[scalajs-bundler]: https://github.com/scalacenter/scalajs-bundler