Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

mibexsoftware/scalajs-octokit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

      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"
  2. Add facades dependency to your build.sbt:

    resolvers += Resolver.jcenterRepo
    libraryDependencies += "laughedelic" %%% "scalajs-octokit" % "<version>"

    (see the latest release version on the badge above)

Example

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))
}

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. 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:

Related projects

  • 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

How is this project different

  • 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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 100.0%