npm.io
1.0.29 • Published 2 years ago

skelly-app

Licence
ISC
Version
1.0.29
Deps
6
Size
34 kB
Vulns
0
Weekly
0

skelly-app

Library allowing your to easily integrate your services with Skelly.

Installation

Installing the package using npm:

npm install skelly-app

Installing the repository using git and launching the demo react app:

git clone https://github.com/Skelly-gg/skelly-app.git

cd skelly-app

npm install

npm run demo

start .\dist\index.html

You can also play with the online demo.

Integration

GraphQL

Here is how you can fetch profiles using GraphQL:

import { getProfile, getProfiles } from "skelly-app";

const profile = await getProfile("N0tail");
console.log(profile)

const profiles = await getProfiles(["Keria", "12728"])
console.log(profiles)

React

You can also easily integrate profiles into your React application using our out-of-the-box component:

import {Profile} from "skelly-app";

export function App() {
  const { fetchProfile, accountId, loadingProfile, profile, errorProfile } =
    useFetchProfile();

  React.useEffect(() => {
    fetchProfile("S1mple");
  }, []);

  if (profile) return <Profile profile={profile} />;
  else return <div>Loading profile...</div>;
}

Utilities

There are convenient utility functions available to process Skelly profiles:

import { getProfile, getAvatar, getName, getLongName } from "skelly-app";

const profile = await getProfile("N0tail");

const avatarURL = getAvatar(profile)
console.log(avatarURL)

const name = getName(profile)
console.log(name)

const longName = getLongName(profile)
console.log(longName)

Keywords