Scala.js facades for octokit/rest.js
This project contains Scala.js facades for octokit/rest.js, the official GitHub REST API v3 client for Node.js.
This project is in active development, there are no published releases yet. Things may break without a warning, so don't rely on it.
🛠 Check installation instructions later, when there is a published release...
-
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
npm install @octokit/rest@15.8.0
-
If it's a Scala.js project use scalajs-bundler and add to your
build.sbt
:Compile/npmDependencies += "@octokit/rest" -> "15.8.0"
-
-
Add facades dependency to your
build.sbt
:resolvers += Resolver.jcenterRepo libraryDependencies += "laughedelic" %%% "scalajs-octokit" % "<version>"
(see the latest release version on the badge above)
Here's a simple usage example:
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))
}
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
. It defines types for the Octokit
client, its options, authentication and pagination.
There's no documentation in the project (yet), but you may find useful these resources:
- octokit/rest.js readme and API docs
- GitHub REST API v3 docs
-
scalajs-io/github-api-node: partial facade for the Github.js library
Github.js provides a minimal higher-level wrapper around Github's API
-
47deg/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
- This is a Scala.js-only (facades) 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